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

assert.soon() with hang analyzer enabled inside a try/finally can lead to an invariant failure in ProgramRegistry

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.4
    • Steps To Reproduce:
      Hide

      The sleep(5000) is to ensure the parallel shell has already exited by the time MongoRunner.runningChildPids() is called.

      ./mongo --nodb --eval 'var cleanup = startParallelShell("1", undefined, true); sleep(5000); try { MongoRunner.runningChildPids(); throw new Error('Simulating assert.soon() failure'); } finally { cleanup() }'
      

      Show
      The sleep(5000) is to ensure the parallel shell has already exited by the time MongoRunner.runningChildPids() is called. ./mongo --nodb --eval 'var cleanup = startParallelShell("1", undefined, true); sleep(5000); try { MongoRunner.runningChildPids(); throw new Error('Simulating assert.soon() failure'); } finally { cleanup() }'
    • Sprint:
      STM 2020-06-29, STM 2020-07-13
    • Linked BF Score:
      50

      Description

      The MongoRunner.runningChildPids() function calls through to getRunningMongoChildProcessIds() in shell_utils_launcher.cpp, which in turn calls wait_for_pid() on all processes in ProgramRegistry::_registeredPids. A JavaScript test of the form

      let cleanup;
      try {
          cleanup = startParallelShell(...);
          assert.soon(...);
          ...
      } finally {
          cleanup();
      }
      

      (for example) would end up calling wait_for_pid() multiple times. The first call to wait_for_pid() via getRunningMongoChildProcessIds() would unregister the pid from ProgramRegistry::_registeredPids and the second call would trigger this invariant.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              richard.samuels Richard Samuels
              Reporter:
              max.hirschhorn Max Hirschhorn
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: