一句话:提出基于约束不可满足性和贝叶斯解释的通用错误定位方法,并实现工具 SHErrLoc。
论文研究如何定位由静态分析发现的程序员错误。作者用通用约束语言表达类型检查、信息流、数据流和指针分析等,将错误视为约束系统不可满足;在“程序大多正确”的假设下,分析可满足与不可满足约束,按贝叶斯原则选择最简错误解释,并识别可能遗漏的假设。实现为 SHErrLoc,并在三种不同分析上评估,包括 GHC 高度表达类型系统的类型推断(类型类、GADT、类型族)。使用已有含错程序对比现有编译器和工具,SHErrLoc 无需语言特定启发式即可更准确地定位错误。
We introduce a general way to locate programmer mistakes that are detected by static analyses. The program analysis is expressed in a general constraint language that is powerful enough to model type checking, information flow analysis, dataflow analysis, and points-to analysis. Mistakes in program analysis result in unsatisfiable constraints. Given an unsatisfiable system of constraints, both satisfiable and unsatisfiable constraints are analyzed to identify the program expressions most likely to be the cause of unsatisfiability. The likelihood of different error explanations is evaluated under the assumption that the programmer’s code is mostly correct, so the simplest explanations are chosen, following Bayesian principles. For analyses that rely on programmer-stated assumptions, the diagnosis also identifies assumptions likely to have been omitted. The new error diagnosis approach has been implemented as a tool called SHErrLoc, which is applied to three very different program analyses, such as type inference for a highly expressive type system implemented by the Glasgow Haskell Compiler—including type classes, Generalized Algebraic Data Types (GADTs), and type families. The effectiveness of the approach is evaluated using previously collected programs containing errors. The results show that when compared to existing compilers and other tools, SHErrLoc consistently identifies the location of programmer errors significantly more accurately, without any language-specific heuristics.