The following example illustrated preparing a program, instrumenting it with discover, and then running it and producing a report on the detected memory access errors. This example uses a simple program that accesses uninitialized data.
% cat test_UMR.c #include <stdio.h> #include <stdlib.h> int main() { // UMR: accessing uninitialized data int *p = (int*) malloc(sizeof(int)); printf("*p = %d\n", *p); free(p); } % cc -g -02 test_UMR.c % a.out *p = 131464 % discover a.out % a.out
The discover output indicates where the uninitialized memory was used and where it was allocated, along with a summary of results, as shown in the following figure.