arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2409.01161cs.PL
收藏

混合测试:C/C++ 原子操作实现的 ABI 兼容性规约与测试

Mix Testing: Specifying and Testing ABI Compatibility of C/C++ Atomics Implementations

Luke Geeson, James Brotherston, Wilco Dijkstra, Alastair F. Donaldson, Lee Smith, Tyler Sorensen, John Wickerson

AI总结:

本文提出混合测试技术及工具 atomic-mixer,用于检测不同编译器对 C/C++ 原子操作采用不同映射并混合链接时产生的 ABI 兼容性错误,在 LLVM 和 GCC 中发现多个新错误,并首次为 Armv8 制定原子操作 ABI 并完成验证。

摘要:

复杂软件的正确性既取决于源代码的正确性,也取决于生成相应二进制代码的编译器的正确性。编译器不仅要保持单个源文件的语义,还必须确保生成的二进制文件能够与其他二进制文件组合成最终的可执行文件。组合的兼容性通过应用二进制接口(ABI)来保证,ABI 规定了调用约定、异常处理等细节。遗憾的是,目前没有针对并发程序的官方 ABI,因此不同的原子操作映射虽然在单独使用时是正确的,但在组合时可能引发错误。事实上,如今将不同编译器生成的二进制文件混合在一起,可能导致最终生成的二进制文件出现错误。我们提出了混合测试(mix testing):一种新技术,用于发现当 C/C++ 测试的指令分别针对多个兼容架构进行编译后再混合在一起时产生的编译器错误。我们定义了一类编译器错误,称为混合错误(mixing bugs),这类错误出现在程序的不同部分使用不同的 C/C++ 原子操作到汇编序列的映射分别编译时。为了证明混合测试的通用性,我们设计并实现了一个工具 atomic-mixer,并用它完成了以下工作:(a) 复现了一个现有的非混合错误,而最先进的并发测试工具仅限于能够发现该错误(表明 atomic-mixer 至少达到了这些工具的能力水平);(b) 在 LLVM 和 GCC 中发现了四个此前未知的混合错误,以及在为 Java 虚拟机提出的映射中发现了一个潜在的混合错误。最后,我们与 Arm 的工程师合作,首次为 Armv8 制定了原子操作 ABI,并使用 atomic-mixer 对 LLVM 和 GCC 编译器进行了针对该 ABI 的验证。

英文摘要:

The correctness of complex software depends on the correctness of both the source code and the compilers that generate corresponding binary code. Compilers must do more than preserve the semantics of a single source file: they must ensure that generated binaries can be composed with other binaries to form a final executable. The compatibility of composition is ensured using an Application Binary Interface (ABI), which specifies details of calling conventions, exception handling, and so on. Unfortunately, there are no official ABIs for concurrent programs, so different atomics mappings, although correct in isolation, may induce bugs when composed. Indeed, today, mixing binaries generated by different compilers can lead to an erroneous resulting binary. We present mix testing: a new technique designed to find compiler bugs when the instructions of a C/C++ test are separately compiled for multiple compatible architectures and then mixed together. We define a class of compiler bugs, coined mixing bugs, that arise when parts of a program are compiled separately using different mappings from C/C++ atomic operations to assembly sequences. To demonstrate the generality of mix testing, we have designed and implemented a tool, atomic-mixer, which we have used: (a) to reproduce one existing non-mixing bug that state-of-the-art concurrency testing tools are limited to being able to find (showing that atomic-mixer at least meets the capabilities of these tools), and (b) to find four previously-unknown mixing bugs in LLVM and GCC, and one prospective mixing bug in mappings proposed for the Java Virtual Machine. Lastly, we have worked with engineers at Arm to specify, for the first time, an atomics ABI for Armv8, and have used atomic-mixer to validate the LLVM and GCC compilers against it.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑