Detecting Uninitialized Variables in C++ with the Clang Static Analyzer

Kristóf Umann, Z. Porkoláb
{"title":"Detecting Uninitialized Variables in C++ with the Clang Static Analyzer","authors":"Kristóf Umann, Z. Porkoláb","doi":"10.14232/actacyb.282900","DOIUrl":null,"url":null,"abstract":"Uninitialized variables have been a source of errors since the beginning of software engineering. Some programming languages (e.g. Java and Python) will automatically zero-initialize such variables, but others, like C and C++, leave their state undefined. While laying aside initialization in C and C++ might be a performance advantage if an initial value can't be supplied, working with such variables is an undefined behavior, and is a common source of instabilities and crashes. To avoid such errors, whenever meaningful initialization is possible, it should be used. Tools for detecting these errors run time have existed for decades, but those require the problematic code to be executed. Since in many cases the number of possible execution paths are combinatoric, static analysis techniques emerged as an alternative. In this paper, we overview the technique for detecting uninitialized C++ variables using the Clang Static Analyzer, and describe various heuristics to guess whether a specific variable was left in an undefined state intentionally. We implemented a prototype tool based on our idea and successfully tested it on large open source projects.","PeriodicalId":187125,"journal":{"name":"Acta Cybern.","volume":"20 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2020-11-19","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"2","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Acta Cybern.","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.14232/actacyb.282900","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 2

Abstract

Uninitialized variables have been a source of errors since the beginning of software engineering. Some programming languages (e.g. Java and Python) will automatically zero-initialize such variables, but others, like C and C++, leave their state undefined. While laying aside initialization in C and C++ might be a performance advantage if an initial value can't be supplied, working with such variables is an undefined behavior, and is a common source of instabilities and crashes. To avoid such errors, whenever meaningful initialization is possible, it should be used. Tools for detecting these errors run time have existed for decades, but those require the problematic code to be executed. Since in many cases the number of possible execution paths are combinatoric, static analysis techniques emerged as an alternative. In this paper, we overview the technique for detecting uninitialized C++ variables using the Clang Static Analyzer, and describe various heuristics to guess whether a specific variable was left in an undefined state intentionally. We implemented a prototype tool based on our idea and successfully tested it on large open source projects.
查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
用Clang静态分析器检测c++中未初始化的变量
自软件工程开始以来,未初始化的变量一直是错误的来源。一些编程语言(如Java和Python)会自动对这些变量进行零初始化,但其他语言,如C和c++,则不定义它们的状态。如果无法提供初始值,那么在C和c++中搁置初始化可能会带来性能优势,但是使用这些变量是一种未定义的行为,并且是不稳定和崩溃的常见来源。为了避免这种错误,只要有可能进行有意义的初始化,就应该使用它。用于在运行时检测这些错误的工具已经存在了几十年,但是这些工具需要执行有问题的代码。由于在许多情况下,可能的执行路径的数量是组合的,因此静态分析技术作为一种替代方法出现了。在本文中,我们概述了使用Clang静态分析器检测未初始化的c++变量的技术,并描述了各种启发式方法来猜测是否故意将特定变量留在未定义状态。我们基于我们的想法实现了一个原型工具,并成功地在大型开源项目中进行了测试。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 去求助
来源期刊
自引率
0.00%
发文量
0
期刊最新文献
Proving the Stability of the Rolling Navigation Inverses of Rational Functions Quantification of Time-Domain Truncation Errors for the Reinitialization of Fractional Integrators On Some Convergence Properties for Finite Element Approximations to the Inverse of Linear Elliptic Operators The Inventory Control Problem for a Supply Chain With a Mixed Type of Demand Uncertainty
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1