计算机科学 ›› 2019, Vol. 46 ›› Issue (11A): 517-523.

• 综合、交叉与应用 • 上一篇    下一篇

基于复杂控制流的源代码内存泄漏静态检测

姬秀娟1, 孙晓卉2, 许静3   

  1. (南开大学滨海学院 天津300270)1;
    (京东数字科技 北京100176)2;
    (南开大学人工智能学院 天津300350) 3
  • 出版日期:2019-11-10 发布日期:2019-11-20
  • 作者简介:姬秀娟(1977-),博士,副教授,主要研究领域为软件分析、软件工程,E-mail:9682561@qq.com。
  • 基金资助:
    本文受天津市自然科学基金重点项目(17JCZDJC30700),天津市科技职称项目(17YFZCGX00610)资助。

Source Code Memory Leak Static Detection Based on Complex Control Flow

JI Xiu-juan1, SUN Xiao-hui2, XU Jing3   

  1. (Binhai College,Nankai University,Tainjin 300270,China)1;
    (Jingdong Digital Technology,Beijing 100176,China)2;
    (College of Artificial Intelligence,Nankai University,Tianjin 300350,China)3
  • Online:2019-11-10 Published:2019-11-20

摘要: C/C++源代码因其手动分配堆内存的特点,造成大量内存泄漏的问题。对于多分支的控制流结构,其内存分配点和释放点具有不确定性,使得内存泄漏检测的难度增大。针对这种复杂控制流中的内存泄漏问题,定义了一种基于路径抽象的内存泄漏分类方法,提出了一种基于投影的模型检测静态分析算法。该算法采用投影技术将原控制流图进行规约和简化;同时,在进行函数间的分析时,融合了Cloning Expands the ICFG和Expanded Supergraph两种方法,构建了一个函数间的内存定义-使用控制流图(Interprocedural Memory Control Flow Graph,IMCFG)。实验表明,该检测方法在有效性和准确率方面明显取得了较好的结果。

关键词: C/C++, 复杂控制流, 静态分析, 内存泄漏, 投影

Abstract: C/C++ source code has a lot of memory leaks because of its manual allocation of heap memory space.Regarding complex control flow with multiple branches in the control flow graph,it is more difficult to detect memory leaks because of the uncertainty of memory allocating and releasing.A memory leak classification method was defined based on path abstraction in complex control flow.A projection-based model detection based on the analysis algorithm was proposed,where the original control flow graph is projected,thus simplifying and regulating the control flow graph.Meanwhile,in the inter-procedural analysis,by combining Cloning Expands the ICFG approach and Expanded Super-graph approach,a Inter-procedural Memory def-use Control Flow Graph(IMCFG) was built.At last,this algorithm is proved to be effective and precise by experiments.

Key words: C/C++, Complex control flow, Memory leak, Projection, Static detection

中图分类号: 

  • TP311
[1]United States Computer Emergency Readiness Team(US-CERT)[OL].https://www.us-cert.gov/ 2016,7,5
[2]cmm5定义bug等级[OL].http://www.docin.com/p-1535244861.html.
[3]LEAK M.[OL].http://www.baike.com/wiki/%E5%86%85%E5%AD %98%E6%B3%84%E6%BC%8F.
[4]王喆.C/C++代码内存泄漏缺陷检测方法研究[D].大连:大连理工大学,2012.
[5]LI M C,CHEN Y J,WANG L Z,et al.Dynamically validating static memory leak warnings[C]∥International Symposium on Software Testing and Analysis Conference.Lugano,Switzerland,2013:112-122
[6]LEE S H,JUNG C H,RAMAN E,et al.Automated memory leak detection for production use[C]∥International Conference on Software Engineering.Hyderabad,India,2014:825-836.
[7]杨宇,张健.程序静态分析技术与工具[J].计算机科学,2004,31(2):171-174.
[8]SOR V,TREIER T,Srirama S N.Improving statistical approach for memory leak detection using machine learning[C]∥International Conference on Software Maintenance.Eindhoven,Netherlands,2013:22-28.
[9]SUI Y L,YE D,XUE J L.Detecting Memory Leakd Statically with Full-Sparse Value-Flow Analysis[J].IEEE Transactions on Software Engineering,2014,40(2):107-122.
[10]LIM W,PARK S,HAN H.Memory leak detection with context awareness[C]∥Reliable and Autonomous ComputationalScie-nce Conference.San Antonio,USA,2012:276-281.
[11]JOY M M,MUELLER W,RAMMIG F J.Source code annotated memory leak detection for soft real time embedded systems with resource constraints[C]∥International Conference on Dependable,Autonomic and Secure Computing.Dalian,China,2014:166-172.
[12]KANVAR V,KHEDKER U P.Heap abstractions for staticanalysis[J].ACM Computing Surveys,2016,49(2):1-29.
[13]付晓毓,朱利,顾伟.基于模型检测的内存泄露静态测试方法[J].微电子学与计算机,2010,27(10):170-173.
[14]XU Z B,ZHANG J,XU Z X.Memory leak detection based on memory state transition Graph[C]∥Asia-Pacific Software Engineering Conference.Ho Chi Minh,Vietnam,2011:33-40.
[15]张仕金.基于Cppcheck软件缺陷模式的研究与定位[D].重庆:重庆大学,2014.
[16]侯洛明.程序静态分析的通用方法[J].计算机学报,1987,2:74-81.
[17]ALT M,MARTIN F.Lecture Notes in Computer Science[M].US,Berlin:Springer,2005.
[18]李平华.过程间数据流分析技术研究[D].南京:东南大学,2004.
[19]CppCheck[OL].trac.cppcheck.net/wiki.
[20]Splint[OL].http://www.splint.org/.
[21]姬秀娟.资源泄漏故障静态分析的关键技术的研究[D].天津:南开大学计算机与控制工程学院,2014.
[22]Standard Performance Evaluation Corporation(SPEC)[OL].http://www.spec.org/cpu/.
[1] 张光华, 高天娇, 陈振国, 于乃文.
基于N-Gram静态分析技术的恶意软件分类研究
Study on Malware Classification Based on N-Gram Static Analysis Technology
计算机科学, 2022, 49(8): 336-343. https://doi.org/10.11896/jsjkx.210900203
[2] 赵静文, 付岩, 吴艳霞, 陈俊文, 冯云, 董继斌, 刘嘉琪.
多线程数据竞争检测技术研究综述
Survey on Multithreaded Data Race Detection Techniques
计算机科学, 2022, 49(6): 89-98. https://doi.org/10.11896/jsjkx.210700187
[3] 杨宏鑫, 宋宝燕, 刘婷婷, 杜岳峰, 李晓光.
基于耦合随机投影的张量填充方法
Tensor Completion Method Based on Coupled Random Projection
计算机科学, 2021, 48(8): 66-71. https://doi.org/10.11896/jsjkx.200900055
[4] 李明磊, 黄晖, 陆余良, 朱凯龙.
SymFuzz:一种复杂路径条件下的漏洞检测技术
SymFuzz:Vulnerability Detection Technology Under Complex Path Conditions
计算机科学, 2021, 48(5): 25-31. https://doi.org/10.11896/jsjkx.200600128
[5] 胡昕彤, 沙朝锋, 刘艳君.
基于随机投影和主成分分析的网络嵌入后处理算法
Post-processing Network Embedding Algorithm with Random Projection and Principal Component Analysis
计算机科学, 2021, 48(5): 124-129. https://doi.org/10.11896/jsjkx.200500058
[6] 陈晨, 周宇, 王永超, 黄志球.
基于情境感知的API个性化推荐
Context-aware Based API Personalized Recommendation
计算机科学, 2021, 48(12): 100-106. https://doi.org/10.11896/jsjkx.201000127
[7] 高帅, 夏良斌, 盛亮, 杜宏亮, 袁媛, 韩和同.
基于投影圆度和遗传算法的空间圆柱面拟合方法
Spatial Cylinder Fitting Based on Projection Roundness and Genetic Algorithm
计算机科学, 2021, 48(11A): 166-169. https://doi.org/10.11896/jsjkx.201100057
[8] 刘栅杉, 朱海龙, 韩晓霞, 穆全起, 贺维.
基于主成分回归和分层置信规则库的企业风险评估模型
Enterprise Risk Assessment Model Based on Principal Component Regression and HierarchicalBelief Rule Base
计算机科学, 2021, 48(11A): 570-575. https://doi.org/10.11896/jsjkx.201200038
[9] 戴宏亮, 梁楚欣.
基于价格趋势驱动的元学习算法在线投资组合策略
Meta-learning Algorithm Based on Trend Promote Price Tracing Online Portfolio Strategy
计算机科学, 2021, 48(11A): 608-615. https://doi.org/10.11896/jsjkx.201100068
[10] 李吟, 李必信.
基于脚本预测和重组的内存泄漏测试加速技术
Memory Leak Test Acceleration Based on Script Prediction and Reconstruction
计算机科学, 2020, 47(9): 31-39. https://doi.org/10.11896/jsjkx.200100075
[11] 张善彬, 袁金钊, 陈辉, 王玉荣, 王杰, 屠长河.
基于标准路牌的车辆自定位
Vehicle Self-localization Based on Standard Road Sign
计算机科学, 2020, 47(7): 97-102. https://doi.org/10.11896/jsjkx.190900011
[12] 邢毓华, 李明星.
基于投影的鲁棒低秩子空间聚类算法
Robust Low Rank Subspace Clustering Algorithm Based on Projection
计算机科学, 2020, 47(6): 92-97. https://doi.org/10.11896/jsjkx.190500074
[13] 宁泽西, 秦绪佳, 陈佳舟.
基于三维场景的视频融合方法
Video Fusion Method Based on 3D Scene
计算机科学, 2020, 47(11A): 281-285. https://doi.org/10.11896/jsjkx.200400049
[14] 王丽星, 曹付元.
基于Huber损失的非负矩阵分解算法
Huber Loss Based Nonnegative Matrix Factorization Algorithm
计算机科学, 2020, 47(11): 80-87. https://doi.org/10.11896/jsjkx.190900144
[15] 郭兰英, 韩睿之, 程鑫.
基于可变形卷积神经网络的数字仪表识别方法
Digital Instrument Identification Method Based on Deformable Convolutional Neural Network
计算机科学, 2020, 47(10): 187-193. https://doi.org/10.11896/jsjkx.191000035
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!