一句话:TSFinder 结合轻量级静态分析提取的类图表示与图分类器,自动判定类是否线程安全并推断其文档。
并发面向对象软件中大量类依赖线程安全保证,但许多类缺乏相关文档,迫使开发者要么仔细阅读实现、要么保守地加锁、要么盲目假定线程安全。为弥补这一缺失,本文提出 TSFinder,自动将类分类为线程安全或线程不安全。其核心思路是将轻量级静态分析提取的类图表示与基于图的分类器相结合:静态分析为每个类构建包含方法与同步等信息的图,分类器在该图上学习判别模式。作者用已知线程安全与不安全的类训练分类器,在未见过的类上达到 94.5% 的准确率,且每个类约需 3 秒,足以高效地为大量类推断线程安全文档。
Thread-safe classes are pervasive in concurrent, object-oriented software. However, many classes lack documentation regarding their safety guarantees under multi-threaded usage. This lack of documentation forces developers who use a class in a concurrent program to either carefully inspect the implementation of the class, to conservatively synchronize all accesses to it, or to optimistically assume that the class is thread-safe. To overcome the lack of documentation, we present TSFinder, an approach to automatically classify classes as supposedly thread-safe or thread-unsafe. The key idea is to combine a lightweight static analysis that extracts a graph representation from classes with a graph-based classifier. After training the classifier with classes known to be thread-safe and thread-unsafe, it achieves an accuracy of 94.5% on previously unseen classes, enabling the approach to infer thread safety documentation with high confidence. The classifier takes about 3 seconds per class, i.e., it is efficient enough to infer documentation for many classes.
DOI 原文 ·
@inproceedings{paperbot4803,
title = {Is this class thread-safe? inferring documentation using graph-based learning},
author = {Andrew Habib and Michael Pradel},
booktitle = {ASE},
year = {2018},
doi = {10.1145/3238147.3238212}
}