paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Bennet: Randomized Specification Testing for Heap-Manipulating Programs

Bennet:面向堆操作程序的随机规约测试
OOPSLA 9(OOPSLA2)2025匹配度 2/10 · 论文研究基于 CN 分离逻辑规约的 C 堆程序随机测试与规约测试生成,属于形式化方法与测试/验证工程,未涉及 LLM/Agent、机器学习系统静态分析、浮点程序分析或贝叶斯程序分析等用户核心交叉方向。虽在 PL 形式化验证与测试领域有工程价值,但与用户研究画像匹配度较低。引用 2 inbox
Zain K Aamer, Benjamin C. Pierce
crossref: 2026-09-10

AI 速览

一句话:提出 Bennet:基于 CN 分离逻辑规约,为堆操作 C 程序自动生成满足前置条件的随机测试输入并发现缺陷。

属性测试在底层语言中常需手工编写生成器,面对复杂内存所有权模式尤其耗时。本文利用 C 规约与验证框架 CN 的受限分离逻辑语法,将前置条件转化为随机输入生成器的基础,并借助 Fulminate 的运行时检查作为规约是否满足的 oracle。作者定义了一个描述生成器的 DSL,形式化其语义,并提出重排值生成时机与传播算术约束的优化。基于该 DSL 实现 Bennet,可为带 CN 规约的 C 函数生成并运行随机测试。在 CN 规约程序语料上的评估表明,Bennet 能高效生成能暴露堆操作程序缺陷的输入。

问题
底层语言(尤其 C)中属性测试的输入生成器通常需手工编写,面对复杂内存所有权模式代价高;需要从规约自动生成满足分离逻辑前置条件的随机输入。
方法
以 CN 的受限分离逻辑语法和 Fulminate 运行时 oracle 为基础,设计描述生成器的 DSL,形式化其语义,并采用重排生成时机和传播算术约束的优化;实现 Bennet 测试工具。
评估
在带有 CN 规约的 C 程序语料上评估 Bennet,展示其能高效生成揭示缺陷的输入,适用于具有复杂前置条件的堆操作程序。
原文摘要(Abstract)

Property-based testing (PBT), widely used in functional languages and interactive theorem provers, works by randomly generating many inputs to a system under test. While PBT has also seen some use in low-level languages like C, users in this setting must craft all their own generators by hand, rather than letting the tool synthesize most generators automatically from types or logical specifications. For low-level code with complex memory ownership patterns, writing such generators can waste significant amounts of time. CN, a specification and verification framework for C, features a streamlined presentation of separation logic that is specially tuned to present only “easy” logical problems to an underlying constraint solver. Prior work on the Fulminate testing framework has shown that CN’s streamlined specifications can also be checked effectively at run time, providing an oracle for testing whether a memory state satisfies a pre-or postcondition. We show that the restricted syntax of CN is also a good basis for deriving generators for random inputs satisfying separation-logic preconditions. We formalize the semantics for a DSL describing these generators, as well as optimizations that reorder when values are generated and propagate arithmetic constraints. Using this DSL, we implement a property-based testing tool, Bennet, that generates and runs random tests for C functions annotated with CN specifications. We evaluate Bennet on a corpus of programs with CN specifications and show that it can efficiently generate bug-revealing inputs for heap-manipulating programs with complex preconditions.

链接与引用

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

BibTeX
@article{paperbot2902,
  title = {Bennet: Randomized Specification Testing for Heap-Manipulating Programs},
  author = {Zain K Aamer and Benjamin C. Pierce},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {9},
  number = {OOPSLA2},
  year = {2025},
  doi = {10.1145/3764115}
}