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

    • 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

      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@mongodb.com Richard Samuels (Inactive)
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: