Finding uninitialized storage errors in C

To help find your uninitialized storage errors, run your program with the Language Environment® TEST run-time and STORAGE options. In the following example:
TEST STORAGE(FD,FB,F9)

the first subparameter of STORAGE is the fill byte for storage allocated from the heap. For example, storage allocated through malloc() is filled with the byte 0xFD. If you see this byte repeated through storage, it is likely uninitialized heap storage.

The second subparameter of STORAGE is the fill byte for storage allocated from the heap but then freed. For example, storage freed by calling free() might be filled with the byte 0xFB. If you see this byte repeated through storage, it is likely storage that was allocated on the heap, but has been freed.

The third subparameter of STORAGE is the fill byte for auto storage variables in a new stack frame. If you see this byte repeated through storage, it is likely uninitialized auto storage.

The values chosen in the example are odd and large, to maximize early problem detection. For example, if you attempt to branch to an odd address you will get an exception immediately.

Example: sample C program for debugging

As an example of uninitialized heap storage, run program CALC with the STORAGE run-time option as STORAGE(FD,FB,F9) to the line labeled PUSHPOP2 and issue the command:
LIST *ptr ;
You will see the byte fill for uninitialized heap storage as the following example shows:
LIST * ptr ;
(* ptr).next = 0xFDFDFDFD
(* ptr).i = -33686019