diff --git a/js/src/jit-test/tests/debug/bug1216261.js b/js/src/jit-test/tests/debug/bug1216261.js new file mode 100644 index 000000000000..71f11fe802c7 --- /dev/null +++ b/js/src/jit-test/tests/debug/bug1216261.js @@ -0,0 +1,15 @@ +// |jit-test| exitstatus: 3 + +if (!('oomAfterAllocations' in this)) + quit(3); + +var g = newGlobal(); +var dbg = new Debugger(g); +dbg.onDebuggerStatement = function(frame) { + oomAfterAllocations(5); + // OOMs here, and possibly again in the error reporter when trying to + // report the OOM, so the shell just exits with code 3. + frame.older.eval("escaped = function() { return y }"); +} +g.eval("function h() { debugger }"); +g.eval("(function () { var y = {p:42}; h(); yield })().next();"); diff --git a/js/src/vm/ScopeObject.cpp b/js/src/vm/ScopeObject.cpp index fb38c623f36e..0c6c69b85b39 100644 --- a/js/src/vm/ScopeObject.cpp +++ b/js/src/vm/ScopeObject.cpp @@ -2354,7 +2354,7 @@ DebugScopes::DebugScopes(JSContext* cx) DebugScopes::~DebugScopes() { - MOZ_ASSERT(missingScopes.empty()); + MOZ_ASSERT_IF(missingScopes.initialized(), missingScopes.empty()); } bool @@ -2454,15 +2454,14 @@ DebugScopes::ensureCompartmentData(JSContext* cx) if (c->debugScopes) return c->debugScopes; - c->debugScopes = cx->runtime()->new_(cx); - if (c->debugScopes && c->debugScopes->init()) - return c->debugScopes; + AutoInitGCManagedObject debugScopes(cx->make_unique(cx)); + if (!debugScopes || !debugScopes->init()) { + ReportOutOfMemory(cx); + return nullptr; + } - if (c->debugScopes) - js_delete(c->debugScopes); - c->debugScopes = nullptr; - ReportOutOfMemory(cx); - return nullptr; + c->debugScopes = debugScopes.release(); + return c->debugScopes; } DebugScopeObject*