Abstract
We present a demand-driven approach to memory leak detection algorithm based on flow- and context-sensitive pointer analysis. The detection algorithm firstly assumes the presence of a memory leak at some program point and then runs a backward analysis to see if this assumption can be disproved. Our algorithm computes the memory abstraction of programs based on points-to graph resulting from flow- and context-sensitive pointer analysis. We have implemented the algorithm in the SUIF2 compiler infrastructure and used the implementation to analyze a set of C benchmark programs. The experimental results show that the approach has better precision with satisfied scalability as expected.
Similar content being viewed by others
References
Hastings R, Joyce B. Fast detection of memory leaks and access errors. In Proc. the Winter USENIX Conference, San Francisco, USA, Winter, 1992, pp.125–136.
Bush W R, Pincus J D, Sielaff D J. A static analyzer for finding dynamic programming errors. Software — Practice and Experience, 2000, 30(7): 775–802.
Xie Y, Aiken A. Saturn: A scalable framework for error detection using Boolean satisfiability. ACM Trans. Program. Lang. Syst., 2007, 29(3): 16.
Evans D. Static detection of dynamic memory errors. In Proc. SIGPLAN Conference on Programming Language Design and Implementation (PLDI’96), Philadelphia, USA, May 21–24, 1996, pp.44–53.
Engler D R, Chen D Y, Chou A. Bugs as inconsistent behavior: A general approach to inferring errors in systems code. In Proc. Symposium on Operating Systems Principles, Chateau Lake Louise, Canada, Oct. 21–24, 2001, pp.57–72.
Hallem S, Chelf B, Xie Y, Engler D. A system and language for building system-specific, static analyses. In Proc. the ACM SIGPLAN 2002 Conference on Programming Language Design and Implementation (PLDI’02), New York, NY, USA, ACM Press, 2002, pp.69–82.
Orlovich M, Rugina R. Memory leak analysis by contradiction. In Proc. SAS, Seoul, Korea, August 29–31, 2006, pp.405–424.
Emami M, Ghiya R, Hendren L J. Context-sensitive interprocedural points-to analysis in the presence of function pointers. In Proc. SIGPLAN Conference on Programming Language Design and Implementation, Orlando, USA, June 20–24, 1994, pp.242–256.
Hind M, Burke M, Carini P, Choi J D. Interprocedural pointer alias analysis. ACM Transactions on Programming Languages and Systems, 1999, 21(4): 848–894.
Rugina R, Rinard M. Pointer analysis for multithreaded programs. In Proc. the ACM SIGPLAN 1999 Conference on Programming Language Design and Implementation (PLDI’99), New York, NY, USA, ACM Press, 1999, pp.77–90.
Xen source. http://www.xensource.com/xen/about.html.
Wilson R P, Lam M S. Efficient context-sensitive pointer analysis for C programs. In Proc. the ACM SIGPLAN 1995 Conference on Programming Language Design and Implementation (PLDI’95), New York, NY, USA, ACM Press, 1995, pp.1–12.
Duesterwald E, Gupta R, Soffa M L. Demand-driven computation of interprocedural data flow. In Proc. the 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’95), New York, NY, USA, ACM Press, 1995, pp.37–48.
Horwitz S, Reps T, Sagiv M. Demand interprocedural dataflow analysis. In Proc. the 3rd ACM SIGSOFT Symposium on Foundations of Software Engineering (SIGSOFT’95), New York, NY, USA, ACM Press, 1995, pp.104–115.
Sharir M, Pnueli A. Two Approaches to Interprocedural Data Flow Analysis. Program Flow Analysis: Theory and Applications, Muchnick S, Jones N (eds.), Prentice Hall Inc, 1981.
Ryder B G, Landi W A, Stocks P A, Zhang S, Altucher R. A schema for interprocedural modification side-effect analysis with pointer aliasing. ACM Trans. Program. Lang. Syst., 2001, 23(2): 105–186.
Austin T M. Pointer-intensive benchmark suite, version 1.1. 1995, http://www.cs.wisc.edu/~austin/ptr-dist.html.
Austin T M, Breach S E, Sohi G S. Efficient detection of all pointer and array access errors. SIGPLAN Not., 1994, 29(6): 290–301.
Cherem S, Princehouse L, Rugina R. Practical memory leak detection using guarded value-flow analysis. In Proc. the 2007 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’07), New York, NY, USA, ACM Press, 2007, pp.480–491.
Heine D L, Lam M S. Static detection of leaks in polymorphic containers. In Proc. ICSE, Shanghai, China, May 20–28, 2006, pp.252–261.
Heine D L, Lam M. A practical flow-sensitive and contextsensitive C and C++ memory leak detector. In Proc. the ACM SIGPLAN 2004 Conference on Programming Language Design and Implementation, San Diego, USA, June 9–11, 2003, pp.168–181.
Xie Y, Aiken A. Context- and path-sensitive memory leak detection. In Proc. the 10th European Software Engineering Conference held jointly with 13th ACM SIGSOFT International Symposium on Foundations of Software Engineering (ESEC/FSE-13), New York, NY, USA, ACM Press, 2005, pp.115–125.
Nurit Dor, Michael Rodeh, Shmuel Sagiv. Checking cleanness in linked lists. In Proc. Static Analysis Symposium, Santa Barbara, USA, June 29–July 1, 2000, pp.115–134.
Hackett B, Rugina R. Region-based shape analysis with tracked locations. In Proc. the 32nd ACM SIGPLAN–SIGACT Symposium on Principles of Programming Aanguages (POPL’05), New York, NY, USA, ACM Press, 2005, pp.310–323.
Author information
Authors and Affiliations
Corresponding author
Additional information
This work is supported by the National Natural Science Foundation of China under Grant Nos. 60725206, 60673118, and 90612009, the National High-Tech Research and Development 863 Program of China under Grant No. 2006AA01Z429, the National Basic Research 973 Program of China under Grant No. 2005CB321802, the Program for New Century Excellent Talents in University under Grant No. NCET-04-0996, and the Hunan Natural Science Foundation under Grant No. 07JJ1011.
Rights and permissions
About this article
Cite this article
Wang, J., Ma, XD., Dong, W. et al. Demand-Driven Memory Leak Detection Based on Flow- and Context-Sensitive Pointer Analysis. J. Comput. Sci. Technol. 24, 347–356 (2009). https://doi.org/10.1007/s11390-009-9229-0
Received:
Revised:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s11390-009-9229-0