Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-10431

Add segfault handler to unit test framework

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.7.5
    • Affects Version/s: None
    • Component/s: Testing Infrastructure
    • Labels:
      None
    • Fully Compatible
    • 0

      Unit tests that cause segfaults (access violations) exit silently (or almost silently) with a non-zero exit code. They should instead print a message indicating that a segfault has occurred, print a stack trace, and then exit.

      Sample code:

          TEST_F(AllNodesDown, ReadFromPrimary) {
      #if 1
              char* crash = reinterpret_cast<char*>(0x123);
              *crash = 'A';
      #endif
              // ...
          }
      

      Program output:

       4:05:01.15 C:\Visual Studio 2010 Projects\mongodev> build\win32\64\dd\mongo\dbclient_rs_test.exe
      Mon Aug 05 04:05:43.286 going to run suite: AllNodesDown
      Mon Aug 05 04:05:43.289          going to run test: ReadFromPrimary
      
       4:05:45.45 C:\Visual Studio 2010 Projects\mongodev> echo %ERRORLEVEL%
      -1073741819
      
      tad@Ubuntu-1204-x64 ~/mongo/mongodev (SERVER-8707-04)
      $ build/linux2/64/dd/mongo/dbclient_rs_test 
      Mon Aug  5 04:15:07.794 going to run suite: AllNodesDown
      Mon Aug  5 04:15:07.801          going to run test: ReadFromPrimary
      Segmentation fault (core dumped)
      
      tad@Ubuntu-1204-x64 ~/mongo/mongodev (SERVER-8707-04)
      $ echo $?
      139
      

            Assignee:
            schwerin@mongodb.com Andy Schwerin
            Reporter:
            tad Tad Marshall
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: