BullseyeCoverage Up Contents Search

Instrumented Executable Crash, Hang or Behavior Change

In the unlikely event an instrumented executable crashes, hangs or changes behavior when built with BullseyeCoverage, you can diagnose the problem by one of the methods listed below.

  1. Disable auto-save. If the symptom changes or goes away, the problem might relate to the creation of the auto-save thread. This does not apply to the small footprint run-time configuration.

  2. Attempt to reproduce the problem with an absolute minimum of code instrumented by BullseyeCoverage. By successively instrumenting different sections of the program, you can narrow down the problematic area. Begin by testing the program with only one source file instrumented by BullseyeCoverage. Test with half the source files instrumented and then again with the other half instrumented. After identifying a subset of the project where the problem occurs, continue splitting the set in half until you narrow down the problematic source file. In a similar fashion, use the directive #pragma BullseyeCoverage off to narrow down the problematic function and then the statement. For more information on selecting code to include or exclude, see Excluding Code. A debugger may help locate the line of code where a crash occurs.

  3. Determine the exact statement where the crash occurs using debugging print statements at various points in the program. By repeatedly running the program, seeing how far the program gets, and moving the print statements, you can narrow down the statement which causes the crash. The following code examples show how to display the source location with a debugging statement.
    /* Display source location in a text-mode program */
    #include <stdio.h>
    ...
    fprintf(stderr, "%s %u\n", __FILE__, __LINE__);
    
    
    /* Display source location in a Windows program */
    #include <windows.h>
    ...
    {
        char buf[99];
        wsprintf(buf, "%s %u\n", __FILE__, __LINE__);
        MessageBox(0, buf, 0, 0);
    }
    
    
    /* Append source location to file in any program */
    #include <stdio.h>
    ...
    {
        FILE * f = fopen("logfile", "a");
        fprintf(f, "%s %u\n", __FILE__, __LINE__);
        fclose(f);
    }
    
  4. Create the smallest program possible which reproduces the problem. To do this, make a copy of your whole instrumented executable, including any static libraries, or shared libraries. Then, remove large portions of the program, building and checking for the symptom after each deletion. Continue removing portions until the symptom stops happening. Then undo your last change.

Updated: 13 Nov 2020