paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Program Reconditioning: Avoiding Undefined Behaviour When Finding and Reducing Compiler Bugs

程序重条件化(Program Reconditioning):在发现与缩减编译器缺陷时避免未定义行为
PLDI 7(PLDI)2023匹配度 4/10 · 论文核心是编译器缺陷测试中的未定义行为规避与差分测试,属于PL/测试方向,不涉及LLM/Agent、面向ML/Agentic程序的静态分析或贝叶斯程序分析;仅因包含浮点舍入误差管理而与用户关注的浮点程序分析有边缘交叉。引用 14 inbox
Bastien Lecoeur, Hasan Mohsin, Alastair F. Donaldson
crossref: 2026-09-10

AI 速览

一句话:提出程序重条件化,使含未定义行为且无检测工具的语言也能做程序生成、差分测试与用例缩减,在 GLSL/WGSL 编译器中发现 57 个缺陷。

程序生成、差分测试与测试用例缩减是发现并简化编译器误编译缺陷的有力手段,但当目标语言存在未定义行为(UB)且没有自动 UB 检测工具时,会误把触发 UB 的程序当作误编译证据,也难以安全地缩减用例。本文提出程序重条件化(program reconditioning):在生成与缩减过程中主动约束并调理程序,使其避开 UB 与浮点舍入误差等非确定性来源。作者据此实现了面向 OpenGL Shading Language 的 GLSLsmith 与面向 WebGPU Shading Language 的 WGSLsmith,首次让 GLSL/WGSL 编译器能够应用差分测试与用例缩减。大规模测试活动中分别在 GLSL 与 WGSL 编译器发现 24 和 33 个缺陷;对照实验表明关闭重条件化后,大量看似触发误编译的测试程序实际只是存在 UB。

问题
在存在未定义行为(UB)却又缺乏 UB 检测工具的着色器语言(GLSL/WGSL)中,程序生成、差分测试与测试用例缩减会把 UB 误判为误编译缺陷,难以有效发现和化简真实的编译器缺陷。
方法
提出程序重条件化:在程序生成与测试用例缩减环节对程序施加约束,避免触发 UB 与浮点舍入误差,并据此构建 GLSLsmith 和 WGSLsmith 两个生成器,用于两种着色器语言的差分测试与用例缩减。
评估
对 GLSL 与 WGSL 编译器开展大规模测试活动,分别发现 24 和 33 个缺陷;并通过关闭重条件化的对照实验,量化了 UB 导致的误报率。
原文摘要(Abstract)

We introduce program reconditioning, a method for allowing program generation and differential testing to be used to find miscompilation bugs, and test-case reduction to be used to simplify bug-triggering programs, even when (a) the programming language of interest features undefined behaviour (UB) and (b) no tools exist to detect and avoid this UB. We present two program generation tools based on our reconditioning idea: GLSLsmith for the OpenGL Shading Language (GLSL), a widely-used language for graphics programming, and WGSLsmith for the WebGPU Shading Language (WGSL), a new language for web-based graphics rendering. GLSL features many UBs, but unlike for languages such as C and C++ no tools exist to detect them automatically. While the WGSL language specification features very limited UB, early WGSL implementations do exhibit UB, for reasons of initial implementation simplicity, making it challenging to test them to quickly detect and eliminate unrelated miscompilation bugs. Thanks to reconditioning, we show that GLSLsmith and WGSLsmith allow differential testing and test-case reduction to be applied to compilers for GLSL and WGSL for the first time, despite the unavailability of UB detection techniques for these languages. Through a large testing campaign, we have found 24 and 33 bugs in GLSL and WGSL compilers, respectively. We present experiments showing that when reconditioning is disabled, compiler testing leads to a high rate of test programs that appear to trigger miscompilation bugs, but actually just feature UB. We also present a novel approach to managing floating-point roundoff error using reconditioning, implemented for both GLSL and WGSL.

链接与引用

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

BibTeX
@article{paperbot1990,
  title = {Program Reconditioning: Avoiding Undefined Behaviour When Finding and Reducing Compiler Bugs},
  author = {Bastien Lecoeur and Hasan Mohsin and Alastair F. Donaldson},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {7},
  number = {PLDI},
  year = {2023},
  doi = {10.1145/3591294}
}