Undefined behavior is idiomatic to C and C++ programming; such behavior is a use of an erroneous program construct for which the languages impose no requirements, such as integer overflows. The paper presents an empirical experiment seeking to probe the extent of undefined behavior executing underneath typical desktop use of a Linux distribution. The analysis is based on an undefined behavior sanitizer implemented in a compiler. According to the results, undefined behavior is common. By completing 59 simple experimental tasks, nearly 11 thousand unique undefined behavior warnings were generated by 32 unique programs and libraries written in C or C++. Of these warnings, most were associated with the Mesa graphics library and generated by interacting with graphical user interfaces. Merely logging into the GNOME desktop environment generated over 500 unique warnings. Of all warnings, the clear majority was about virtual table pointers. The associated stack traces were also lengthy in general. With these and other results, the paper contributes to the empirical literature on C and C++.
翻译:未定义行为是C与C++编程中的习语性特征;此类行为指使用了语言未作任何要求的错误程序构造,例如整数溢出。本文通过一项实证实验,试图探究Linux发行版典型桌面使用过程中底层执行的未定义行为范围。该分析基于编译器中实现的未定义行为检测器。结果显示,未定义行为相当普遍。通过完成59个简单实验任务,由32个用C或C++编写的程序及库产生了近11000条独特的未定义行为警告。其中,多数警告与Mesa图形库相关,且通过交互图形用户界面产生。仅登录GNOME桌面环境就生成了超过500条独特警告。在所有警告中,绝大多数涉及虚表指针。相关的堆栈回溯通常也较长。结合这些及其他结果,本文为关于C与C++的实证文献做出了贡献。