paperbot · PL 论文追踪

全部论文 待读 收藏

CiL-Agent: Compiler-in-the-Loop LLM Agent for Memory-Safe C Program Repair

CiL-Agent:面向内存安全 C 程序修复的编译器在环 LLM 智能体
ASE Proceedings of the 41st IEEE/ACM International Conference on Automated Software Engineering2026引用 0 inbox
Yang Shen, Yating Zhang, Jiaqiang Yao, Minghao Liu, Wei Dong
crossref: 2026-10-09

AI 速览

一句话:把 GCC、Clang 静态分析器与 Valgrind 嵌入 LLM 生成回路,以结构化三维反馈修复 C 程序的内存安全缺陷。

自动程序修复在 Java、Python 等托管语言上进展迅速,但 C 语言由于手动内存管理,补丁可能在通过编译与功能测试的同时悄悄引入泄漏、释放后使用或双重释放等内存安全缺陷。已有 LLM 修复方法反馈贫乏:或完全无执行反馈,或仅有通过/失败二值信号,或仅使用非结构化、未打分的 sanitizer 文本。本文提出 CiL-Agent,将 GCC、Clang 静态分析器与 Valgrind 紧耦合进 LLM 生成循环,把工具诊断解析为编译可达性、静态可证性与动态内存安全三维结构化反馈;并采用两阶段策略,先采样候选补丁并综合打分(Best-of-N),再在精确工具反馈下对最优候选进行迭代精化。在覆盖 11 类 CWE 的 1000 个真实 C 漏洞上,CiL-Agent 达到 88.2% Pass@1,其中 87.3% 的补丁内存安全,显著优于五个修复基线与五个现代编程智能体;1000 任务消融显示工具链集成与迭代精化各自不可或缺(分别下降 44.3 与 35.2 个百分点),且工具链集成是最关键组件;post-cutoff 基准进一步表明增益并非源于训练数据记忆。

问题
C 语言缺乏内存管理保护,LLM 生成的修复补丁即使通过编译和功能测试,也可能静默引入内存安全缺陷;现有 LLM 修复方法所依赖的反馈(无执行、二值通过/失败、非结构化 sanitizer 文本)过于贫乏,无法防范这类风险。
方法
CiL-Agent 将 GCC、Clang 静态分析器与 Valgrind 集成进 LLM 生成回路,把诊断结果解析为编译可达性、静态可证性与动态内存安全三个维度的结构化反馈,并采用两阶段策略:先 Best-of-N 采样并综合打分候选补丁,再依据精确工具反馈对最优候选迭代精化。
评估
在涵盖 11 类 CWE 的 1000 个真实 C 漏洞上评测,与五个修复基线和五个现代编程智能体对比,报告 Pass@1 与内存安全补丁比例,并进行 1000 任务消融实验及 post-cutoff 基准验证。
原文摘要(Abstract)

Automated Program Repair (APR) has advanced rapidly on managed languages such as Java and Python, yet C—the bedrock of systems software—remains far harder to repair safely. The difficulty is specific to C: as an unmanaged language with manual memory management, a patch can compile and pass every functional test while silently introducing a memory-safety defect (a leak, use-after-free, or double free) that managed-language tests would never expose, making such “fixes” potentially worse than no fix. Existing LLM-based repair offers little defense, as it learns from impoverished feedback—no execution at all (APPATCH), binary pass/fail signals (ChatRepair), or loosely-structured, unscored sanitizer text (VRpilot). We present CiL-Agent (Compiler-in-the-Loop Agent), which tightly integrates GCC, the Clang Static Analyzer, and Valgrind into the LLM generation loop, parsing their diagnostics into structured, three-dimensional feedback: compilation reachability, static provability, and dynamic memory safety. A two-phase strategy first samples and composite-scores candidate patches (Best-of-N), then refines the best under precise tool feedback. On 1,000 real-world C vulnerabilities spanning 11 CWE categories, CiL-Agent attains 88.2% Pass@1 with 87.3% memory-safe patches, outperforming five repair baselines (by 8.3–58.4pp, all p<0.001, McNemar’s test) and five modern coding agents by a wide margin. A full 1,000-task ablation shows toolchain integration and iterative refinement are independently essential (−44.3 and −35.2 percentage points), with toolchain integration the single most critical component, and a post-cutoff benchmark confirms the gains are not due to training-data memorization.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot12260,
  title = {CiL-Agent: Compiler-in-the-Loop LLM Agent for Memory-Safe C Program Repair},
  author = {Yang Shen and Yating Zhang and Jiaqiang Yao and Minghao Liu and Wei Dong},
  booktitle = {ASE},
  year = {2026},
  doi = {10.1145/3832783.3837493}
}