diff --git a/js/src/jit-test/tests/debug/gc-08.js b/js/src/jit-test/tests/debug/gc-08.js new file mode 100644 index 00000000000..4d5e16a39c4 --- /dev/null +++ b/js/src/jit-test/tests/debug/gc-08.js @@ -0,0 +1,22 @@ +// |jit-test| debug +// Debuggers with enabled throw hooks should not be GC'd even if they are +// otherwise unreachable. + +load(libdir + "asserts.js"); + +var g = newGlobal('new-compartment'); +var actual = 0; +var expected = 0; + +function f() { + for (var i = 0; i < 20; i++) { + var dbg = new Debug(g); + dbg.hooks = {num: i, throw: function (stack, exc) { actual += this.num; }}; + expected += i; + } +} + +f(); +gc(); +assertThrowsValue(function () { g.eval("throw 'fit';"); }, "fit"); +assertEq(actual, expected); diff --git a/js/src/jsdbg.h b/js/src/jsdbg.h index 85ad2d73a9a..9761fdb986a 100644 --- a/js/src/jsdbg.h +++ b/js/src/jsdbg.h @@ -214,7 +214,7 @@ class Debug { bool Debug::hasAnyLiveHooks() const { - return observesDebuggerStatement(); + return enabled && (hasDebuggerHandler || hasThrowHandler); } bool