Detecting Memory-Related Bugs by Tracking Heap Memory Management of C++ Smart Pointers
The smart pointer mechanism, which is improved in the continuous versions of the C++ standards over the last decade, is designed to prevent memory-leak bugs by automatically deallocating the managed memory blocks. However, not all kinds of memory errors can be immunized by adopting this mechanism. For example, dereferencing a null smart pointer will lead to a software failure. Due to the lack of specialized support for smart pointers, the off-the-shelf C++ static analyzers cannot effectively reveal these bugs.
In this paper, we propose a static approach to detecting memory-related bugs by tracking the heap memory management of smart pointers. The behaviors of smart pointers are modeled during their lifetime to trace the state transitions of managed memory blocks. And the specially designed checkers are used to check the state changes according to five collected error patterns. To evaluate the effectiveness of our approach, we implement it on the top of the Clang Static Analyzer. A set of handmade code snippets, as well as nine popular open-source C++ projects, are used to compare our tool against four other analyzers. The results show that our approach can successfully discover nearly all the built-in errors. And 442 out of 648 reports generated from the open-source projects are true positives after manual reviewing, where the bugs of dereferencing null smart pointers are most frequently reported. To further confirm our reports, we design patches for Aria2, Restbed, MySQL and LLVM, in which seven pull requests covering 76 bug reports have been merged by the developers up to now. The results indicate that pointers should always be carefully used even after migrated to smart pointers and static analysis upon specialized models can effectively detect such errors.
Thu 18 NovDisplayed time zone: Hobart change
19:00 - 20:00 | Bugs IIResearch Papers / NIER track / Tool Demonstrations at Koala Chair(s): Annibale Panichella Delft University of Technology | ||
19:00 20mTalk | Detecting Memory-Related Bugs by Tracking Heap Memory Management of C++ Smart Pointers Research Papers Xutong Ma State Key Laboratory of Computer Science, Institute of Software, Chinese Academy of Sciences, Beijing, China, Jiwei Yan Institute of Software at Chinese Academy of Sciences, China, Wei Wang State Key Laboratory of Computer Science, Institute of Software, Chinese Academy of Sciences, Beijing, China, Jun Yan Institute of Software at Chinese Academy of Sciences, China, Jian Zhang Institute of Software at Chinese Academy of Sciences, China, Zongyan Qiu Peking University | ||
19:20 20mTalk | Understanding and Detecting Performance Bugs in Markdown Compilers Research Papers Penghui Li The Chinese University of Hong Kong, Yinxi Liu The Chinese University of Hong Kong, Wei Meng Chinese University of Hong Kong Pre-print | ||
19:40 10mTalk | Bugs4Q: A Benchmark of Real Bugs for Quantum Programs NIER track Pengzhan Zhao Kyushu University, Jianjun Zhao Kyushu University, Zhongtao Miao Kyushu University, Shuhan Lan Kyushu University | ||
19:50 5mTalk | Muskit: A Mutation Analysis Tool for Quantum Software Testing Tool Demonstrations Eñaut Mendiluze Usandizaga Simula Research Laboratory, Norway, Shaukat Ali Simula Research Laboratory, Norway, Paolo Arcaini National Institute of Informatics
, Tao Yue Nanjing University of Aeronautics and Astronautics | ||
19:55 5mTalk | JTDog: a Gradle Plugin for Dynamic Test Smell Detection Tool Demonstrations Masayuki Taniguchi Osaka University, Shinsuke Matsumoto Osaka University, Shinji Kusumoto Osaka University |