Bug 857091: Debugger: Don't ignore errors returned by dbg->addDebuggeeGlobal in addAllGlobalsAsDebuggees. r=jorendorff
authorJim Blandy <jimb@mozilla.com>
Mon, 20 May 2013 12:15:58 -0700
changeset 143941 97663ef54fef9defcd8ce8925477452c8d1bd4e9
parent 143940 b0d07be09b86c25f018504cc4852ccb63f9e8775
child 143942 82083cb7fcf4a10a40ed7ce226d8dd87bcf9d5d8
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs857091
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 857091: Debugger: Don't ignore errors returned by dbg->addDebuggeeGlobal in addAllGlobalsAsDebuggees. r=jorendorff
js/src/jit-test/tests/debug/Debugger-debuggees-21.js
js/src/vm/Debugger.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/Debugger-debuggees-21.js
@@ -0,0 +1,12 @@
+// Errors adding globals in addAllGlobalsAsDebuggees should be reported.
+
+// The exception that might be thrown in this test reflects our inability
+// to change compartments to debug mode while they have frames on the
+// stack. If we run this test with --debugjit, it won't throw an error at
+// all, since all compartments are already in debug mode. So, pass if the
+// script completes normally, or throws an appropriate exception.
+try {
+  newGlobal().eval("(new Debugger).addAllGlobalsAsDebuggees();");
+} catch (ex) {
+  assertEq(!!(''+ex).match(/can't start debugging: a debuggee script is on the stack/), true);
+}
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -1940,17 +1940,18 @@ Debugger::addAllGlobalsAsDebuggees(JSCon
     AutoDebugModeGC dmgc(cx->runtime);
     for (CompartmentsIter c(cx->runtime); !c.done(); c.next()) {
         if (c == dbg->object->compartment())
             continue;
         c->zone()->scheduledForDestruction = false;
         GlobalObject *global = c->maybeGlobal();
         if (global) {
             Rooted<GlobalObject*> rg(cx, global);
-            dbg->addDebuggeeGlobal(cx, rg, dmgc);
+            if (!dbg->addDebuggeeGlobal(cx, rg, dmgc))
+                return false;
         }
     }
 
     args.rval().setUndefined();
     return true;
 }
 
 JSBool