Skip Navigation Links | |
Exit Print View | |
Oracle Solaris Studio 12.3: Discover and Uncover User's Guide Oracle Solaris Studio 12.3 Information Library |
2. Memory Error Discovery Tool (Discover)
Requirements for Using Discover
Binaries Must Be Prepared Correctly
Binaries That Use Preloading or Auditing Cannot Be Used
Binaries That Redefine Standard Memory Allocation Functions Can Be Used
Instrumenting a Prepared Binary
Instrumenting Shared Libraries
SUNW_DISCOVER_OPTIONS Environment Variable
SUNW_DISCOVER_FOLLOW_FORK_MODE Environment Variable
Running an Instrumented Binary
Memory Access Errors and Warnings
Interpreting Discover Error Messages
Limitations When Using Discover
Only Annotated Code is Instrumented
Machine Instruction Might Differ From Source Code
Compiler Options Affect the Generated Code
System Libraries Can Affect the Errors Reported
Custom Memory Management Can Affect the Accuracy of the Data
Out of Bounds Errors for Static and Automatic Arrays Cannot Be Detected
The following is an example of 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 shows where the uninitialized memory was used and where it was allocated, along with summary of results.