paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Exploring C semantics and pointer provenance

探索 C 语义与指针来源(pointer provenance)
POPL 3(POPL)2019匹配度 2/10 · 论文聚焦 C 指针来源的形式语义、标准兼容性与 CHERI/SPEC 工程评估,属于编程语言形式语义与程序分析基础设施;未涉及 LLM/Agent、机器学习系统、浮点或贝叶斯程序分析,与画像的核心交叉方向不匹配。引用 54 inbox
Kayvan Memarian, Victor B. F. Gomes, Brooks Davis, Stephen Kell, Alexander Richardson, Robert N. M. Watson, Peter Sewell
crossref: 2026-09-10

AI 速览

一句话:提出两种 C 指针来源语义方案,将其实现为可执行测试预言,并结合 CHERI 移植与 SPEC 插桩评估。

C 语言中指针与内存对象的语义长期存在争议:值既非纯抽象也非纯具体,语言暴露其表示,而编译器优化依赖来源与初始化状态而非仅运行时表示。ISO WG14 标准对此模糊,且与实际用法和主流编译器行为不一致。本文系统探索 ISO C 与实际 C 中内存对象和指针的源语言语义,尤其聚焦 pointer provenance,提出两种一致方案:是否用整数跟踪 provenance。作者将语义实现为可执行测试预言,整合并扩展 Cerberus,提供 Web GUI,并用测试用例实验评估;还分析 FreeBSD 移植到 CHERI 的改动与行为,开发运行时插桩工具检测 provenance 违规并应用于 SPEC 基准,并与 Lee 等人的 twin-allocation LLVM 语义源语言变体比较。论文指出各方案利弊与开放问题,并描述与 WG14 的标准互动。

问题
C 的指针与内存对象语义长期不清,ISO 标准、主流编译器优化和实际 C 代码所依赖的语义(尤其 pointer provenance)彼此存在分歧。
方法
作者提出两种一致的源语言语义方案(用/不用整数跟踪 provenance),将其实现为可执行测试预言并整合进扩展后的 Cerberus,同时用 FreeBSD/CHERI 移植分析、SPEC 运行时插桩及与 LLVM twin-allocation 方案比较来评估。
评估
通过测试用例库、FreeBSD 到 CHERI 的移植改动与行为分析、SPEC 基准上的运行时插桩,以及与 Lee 等人 LLVM 语义提案的源语言变体比较,评估方案的可行性与影响。
原文摘要(Abstract)

The semantics of pointers and memory objects in C has been a vexed question for many years. C values cannot be treated as either purely abstract or purely concrete entities: the language exposes their representations, but compiler optimisations rely on analyses that reason about provenance and initialisation status, not just runtime representations. The ISO WG14 standard leaves much of this unclear, and in some respects differs with de facto standard usage --- which itself is difficult to investigate. In this paper we explore the possible source-language semantics for memory objects and pointers, in ISO C and in C as it is used and implemented in practice, focussing especially on pointer provenance. We aim to, as far as possible, reconcile the ISO C standard, mainstream compiler behaviour, and the semantics relied on by the corpus of existing C code. We present two coherent proposals, tracking provenance via integers and not; both address many design questions. We highlight some pros and cons and open questions, and illustrate the discussion with a library of test cases. We make our semantics executable as a test oracle, integrating it with the Cerberus semantics for much of the rest of C, which we have made substantially more complete and robust, and equipped with a web-interface GUI. This allows us to experimentally assess our proposals on those test cases. To assess their viability with respect to larger bodies of C code, we analyse the changes required and the resulting behaviour for a port of FreeBSD to CHERI, a research architecture supporting hardware capabilities, which (roughly speaking) traps on the memory safety violations which our proposals deem undefined behaviour. We also develop a new runtime instrumentation tool to detect possible provenance violations in normal C code, and apply it to some of the SPEC benchmarks. We compare our proposal with a source-language variant of the twin-allocation LLVM semantics proposal of Lee et al. Finally, we describe ongoing interactions with WG14, exploring how our proposals could be incorporated into the ISO standard.

链接与引用

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

BibTeX
@article{paperbot637,
  title = {Exploring C semantics and pointer provenance},
  author = {Kayvan Memarian and Victor B. F. Gomes and Brooks Davis and Stephen Kell and Alexander Richardson and Robert N. M. Watson and Peter Sewell},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {3},
  number = {POPL},
  year = {2019},
  doi = {10.1145/3290380}
}