-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
Affects Version/s: 2.4.6, 2.5.2
-
Component/s: JavaScript
-
Fully Compatible
-
ALL
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
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.