一句话:提出 SmallRace,将 Smalltalk 翻译为统一指针类型的 SmallIR,用过程间线程敏感指针分析实现静态竞态检测。
Smalltalk 至今仍被大量遗留代码库使用,而竞态条件是其多线程编程的关键难题:纯动态类型允许任意对象赋给任意变量,也可派生线程执行以对象传入的匿名代码块,竞态易引入却难在运行时防范。本文提出 SmallRace,一个面向多线程动态语言的静态竞态检测框架。其核心是 SmallIR:所有变量统一声明为泛型指针类型的 LLVM IR 子集,据此设计过程间、线程敏感的指针分析以推断动态变量具体类型。SmallRace 自动把 VisualWorks 的 Smalltalk 源码翻译为 SmallIR,支持大部分现代语法,并生成带详细调试信息的竞态报告。作者在超过百万行的企业生产代码库上评估,发现数十个复杂竞态。
Smalltalk, one of the first object-oriented programming languages, has had a tremendous influence on the evolution of computer technology. Due to the simplicity and productivity provided by the language, Smalltalk is still in active use today by many companies with large legacy codebases and with new code written every day. A crucial problem in Smalltalk programming is the race condition. Like in any other parallel language, debugging race conditions is inherently challenging, but in Smalltalk, it is even more challenging due to its dynamic nature. Being a purely dynamically-typed language, Smalltalk allows assigning any object to any variable without type restrictions, and allows forking new threads to execute arbitrary anonymous code blocks passed as objects. In Smalltalk, race conditions can be introduced easily, but are difficult to prevent at runtime. We present SmallRace, a novel static race detection framework designed for multithreaded dynamic languages, with a focus on Smalltalk. A key component of SmallRace is SmallIR, a subset of LLVM IR, in which all variables are declared with the same type-a generic pointer 18✶. This allows SmallRace to design an effective interprocedural thread-sensitive pointer analysis to infer the concrete types of dynamic variables. SmallRace automatically translates Smalltalk source code into SmallIR, supports most of the modern Smalltalk syntax in Visual Works, and generates actionable race reports with detailed debugging information. Importantly, SmallRace has been used to analyze a production codebase in a large company with over a million lines of code, and it has found tens of complex race conditions in the production code.
@inproceedings{CuiGUPLH23,
title = {SmallRace: Static Race Detection for Dynamic Languages - A Case on Smalltalk},
author = {Siwei Cui and Yifei Gao and Rainer Unterguggenberger and Wilfried Pichler and Sean Livingstone and Jeff Huang},
booktitle = {ICSE},
year = {2023},
doi = {10.1109/icse48619.2023.00102}
}