[论文解读] Cause Clue Clauses: Error Localization using Maximum Satisfiability
本文提出了一种名为 Cause Clue Clauses 的新型错误定位技术,将程序调试问题转化为最大可满足性(MAX-SAT)问题。通过符号化编码程序执行轨迹并识别失败执行中的不可满足子句,该方法能够精确定位最小的代码修改以修复错误,在 C 程序调试中实现了高精度与可扩展性,并通过基准测试套件的实验验证了其有效性。
Much effort is spent everyday by programmers in trying to reduce long, failing execution traces to the cause of the error. We present a new algorithm for error cause localization based on a reduction to the maximal satisfiability problem (MAX-SAT), which asks what is the maximum number of clauses of a Boolean formula that can be simultaneously satisfied by an assignment. At an intuitive level, our algorithm takes as input a program and a failing test, and comprises the following three steps. First, using symbolic execution, we encode a trace of a program as a Boolean trace formula which is satisfiable iff the trace is feasible. Second, for a failing program execution (e.g., one that violates an assertion or a post-condition), we construct an unsatisfiable formula by taking the trace formula and additionally asserting that the input is the failing test and that the assertion condition does hold at the end. Third, using MAX-SAT, we find a maximal set of clauses in this formula that can be satisfied together, and output the complement set as a potential cause of the error. We have implemented our algorithm in a tool called bug-assist for C programs. We demonstrate the surprising effectiveness of the tool on a set of benchmark examples with injected faults, and show that in most cases, bug-assist can quickly and precisely isolate the exact few lines of code whose change eliminates the error. We also demonstrate how our algorithm can be modified to automatically suggest fixes for common classes of errors such as off-by-one.
研究动机与目标
- 为高效定位长程序执行轨迹中的根本原因提供解决方案。
- 将错误定位问题转化为最大可满足性(MAX-SAT)问题,以实现可扩展且精确的调试。
- 实现对常见错误模式(如 off-by-one 或比较操作符错误)的自动化修复建议。
- 将该技术集成到 IDE 中,实现实时开发过程中的开发者辅助。
提出的方法
- 对程序进行符号执行,生成以合取范式(CNF)表示的布尔轨迹公式,以表示可行的程序执行路径。
- 通过添加硬约束来扩展轨迹公式,以断言失败的测试输入以及被违反的后置条件或断言。
- 使用部分 MAX-SAT 求解器,找出可满足的最大软子句集合(代表程序语句),并将补集识别为潜在的错误原因。
- 按源代码语句对子句进行分组,将未满足的子句映射回具体的代码行,以实现错误定位。
- 利用增量 SAT 求解与不可满足核心提取技术,提升在大型轨迹上的性能。
- 通过将搜索限制在常见错误模式(如 off-by-one 或操作符替换)范围内,扩展该方法以自动生成修复建议。
实验结果
研究问题
- RQ1MAX-SAT 是否能有效用于定位使失败执行变为可行的最小代码修改集合?
- RQ2该方法在真实世界 C 程序中,能否精确且高效地识别出导致失败的具体代码行?
- RQ3MAX-SAT 的形式化是否可扩展以自动生成常见错误类别的合理修复建议?
- RQ4与现有故障定位技术相比,该方法的性能与可扩展性如何?
主要发现
- 在注入故障的 5 个 Siemens 基准程序中,BugAssist 准确定位了所有故障代码行,展现出高精度。
- 在所有测试案例中,该工具均识别出修改后可消除失败的最小语句集合,通常能将错误精确定位到单一行代码。
- 结合轨迹压缩技术后,该方法在真实程序中表现出良好的可扩展性,有效避免了状态空间爆炸问题。
- 该工具响应速度快,适合集成到 IDE 中,实现实时调试辅助。
- 对于 off-by-one 或比较操作符错误等常见错误模式,该工具能以极少用户输入自动生成正确修复建议。
- 实际中枚举的最小错误集合数量保持较小,提升了工具的可用性与可解释性。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。