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

Add segfault handler to unit test framework

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 2.7.5
    • Testing Infrastructure
    • None
    • Fully Compatible
    • 0

    Description

      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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: