arXiv:2603.29109cs.SEcs.AI2026-03被引 1

用结构化语义锚定提升大模型故障定位精度,解决语义错误难定位问题。

SemLoc: Structured Grounding of Free-Form LLM Reasoning for Fault Localization

  • 将大模型自由推理转为带类型程序锚点的封闭中间表示
  • 在250个测试中达到Top-1准确率42.8%,仅需检查7.6%代码行
  • 通过反事实验证识别主因约束,适合调试复杂语义缺陷

故障定位旨在识别导致程序失败的代码位置。现有方法依赖语法谱信号(如语句覆盖率、控制流分歧或依赖可达性)对可疑代码排序,但在语义错误场景下失效——失败与通过执行路径相同,仅语义意图是否满足不同。近期基于大模型的方法引入语义推理,但输出随机且不可验证,难以跨测试交叉比对,也无法区分根本原因与连锁效应。本文提出SemLoc框架,通过结构化语义锚定实现大模型推理的可追溯性。该框架将自由形式的大模型推理转化为封闭中间表示,将每个推断属性绑定到有类型的程序锚点,支持运行时检查和结构溯源。通过仪器化程序生成语义违规谱——按测试构建的约束-测试矩阵,据此计算可疑度分数,类比覆盖率方法。进一步采用反事实验证步骤,剔除过度近似约束,精准定位主因违规。在包含250个含单语义错误的Python程序的SemFault-250数据集上评估,SemLoc优于五种覆盖、缩减和大模型基线,达Top-1准确率42.8%、Top-3准确率68%,检测范围缩小至7.6%可执行代码行;反事实验证额外提升12%准确率,并识别出主要因果语义约束。

原文摘要 · Abstract (English)

Fault localization identifies program locations responsible for observed failures. Existing techniques rank suspicious code using syntactic spectra--signals derived from execution structure such as statement coverage, control-flow divergence, or dependency reachability. These signals collapse for semantic bugs, where failing and passing executions follow identical code paths and differ only in whether semantic intent is satisfied. Recent LLM-based approaches introduce semantic reasoning but produce stochastic, unverifiable outputs that cannot be systematically cross-referenced across tests or distinguish root causes from cascading effects. We present SemLoc, a fault localization framework based on structured semantic grounding. SemLoc converts free-form LLM reasoning into a closed intermediate representation that binds each inferred property to a typed program anchor, enabling runtime checking and attribution to program structure. It executes instrumented programs to construct a semantic violation spectrum--a constraint-by-test matrix--from which suspiciousness scores are derived analogously to coverage-based methods. A counterfactual verification step further prunes over-approximate constraints and isolates primary causal violations. We evaluate SemLoc on SemFault-250, a corpus of 250 Python programs with single semantic faults. SemLoc outperforms five coverage-, reduction-, and LLM-based baselines, achieving Top-1 accuracy of 42.8% and Top-3 of 68%, while reducing inspection to 7.6% of executable lines. Counterfactual verification provides an additional 12% accuracy gain and identifies primary causal semantic constraints.

故障定位大模型推理语义分析

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。