C和C++中的未定义行为:桌面使用场景的实验
Undefined Behavior in C and C++: An Experiment With Desktop Use Cases
AI总结:
通过编译器实现的未定义行为检测器,实验发现Linux桌面环境下C/C++程序普遍存在未定义行为,59个任务产生近1.1万条警告,多数来自Mesa图形库和GUI交互。
摘要:
未定义行为是C和C++编程中的惯用现象;这类行为是指使用了语言不施加任何要求的错误程序构造,例如整数溢出。本文通过实证实验,探究在Linux发行版的典型桌面使用中,底层执行的未定义行为的程度。分析基于编译器中实现的未定义行为检测器。根据结果,未定义行为很常见。通过完成59个简单的实验任务,由32个用C或C++编写的独特程序和库生成了近1.1万条独特的未定义行为警告。其中,大多数警告与Mesa图形库相关,并通过与图形用户界面交互产生。仅登录GNOME桌面环境就生成了超过500条独特警告。在所有警告中,绝大多数是关于虚表指针的。相关的堆栈跟踪通常也很长。凭借这些及其他结果,本文为关于C和C++的实证文献做出了贡献。
英文摘要:
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++.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。