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

Interrupting Javascript during V8Scope initialization causes resource leak

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.5.3
    • Affects Version/s: 2.4.6, 2.5.2
    • Component/s: JavaScript
    • Labels:
    • Fully Compatible
    • ALL

      The V8Scope constructor is not exception-safe, and will leak V8 isolates if an exception is thrown. Thus, if a user executes a Javascript operation that acquires a new scope, and then interrupts that operation while its initialization files are being executed (assert.js, types.js), the half-constructed V8Scope object will be leaked. The initialization files can take on the order of ~100 milliseconds to run.

      Reproduce in master with:

      for (;;) { db.runCommand({eval: function(){}, maxTimeMS: 1}); }
      

      On my local machine, the above leaks 2GB in ~30 seconds. The same occurs in 2.4.6 using killOp instead of maxTimeMS. No V8Scope is ever successfully constructed, and the scope pool remains empty.

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            rassi J Rassi
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: