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