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

XMLWordPrintableJSON

    • Fully Compatible
    • ALL
    • v4.4
    • 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() }'
    • STM 2020-06-29, STM 2020-07-13
    • 50
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

              Assignee:
              Richard Samuels (Inactive)
              Reporter:
              Max Hirschhorn
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: