Automatic detection of uninitialized variables

  • Authors:
  • Thi Viet Nga Nguyen;François Irigoin;Corinne Ancourt;Fabien Coelho

  • Affiliations:
  • Ecole des Mines de Paris, Fontainebleau, France;Ecole des Mines de Paris, Fontainebleau, France;Ecole des Mines de Paris, Fontainebleau, France;Ecole des Mines de Paris, Fontainebleau, France

  • Venue:
  • CC'03 Proceedings of the 12th international conference on Compiler construction
  • Year:
  • 2003

Quantified Score

Hi-index 0.00

Visualization

Abstract

One of the most common programming errors is the use of a variable before its definition. This undefined value may produce incorrect results, memory violations, unpredictable behaviors and program failure. To detect this kind of error, two approaches can be used: compile-time analysis and run-time checking. However, compile-time analysis is far from perfect because of complicated data and control flows as well as arrays with non-linear, indirection subscripts, etc. On the other hand, dynamic checking, although supported by hardware and compiler techniques, is costly due to heavy code instrumentation while information available at compile-time is not taken into account. This paper presents a combination of an efficient compile-time analysis and a source code instrumentation for run-time checking. All kinds of variables are checked by PIPS, a Fortran research compiler for program analyses, transformation, parallelization and verification. Uninitialized array elements are detected by using imported array region, an efficient inter-procedural array data flow analysis. If exact array regions cannot be computed and compile-time information is not sufficient, array elements are initialized to a special value and their utilization is accompanied by a value test to assert the legality of the access. In comparison to the dynamic instrumentation, our method greatly reduces the number of variables to be initialized and to be checked. Code instrumentation is only needed for some array sections, not for the whole array. Tests are generated as early as possible. In addition, programs can be proved to be free from used-before-set errors statically at compile-time or, on the contrary, have real undefined errors. Experiments on SPEC95 CFP show encouraging results on analysis cost and run-time overheads.