Fix a breakpoint GC bug found by billm. See bug 677386 comment 8, first paragraph. r=billm on IRC.

This commit is contained in:
Jason Orendorff 2011-08-24 18:42:19 -05:00
parent 01972cd38f
commit 51d9a1ec05
2 changed files with 26 additions and 1 deletions

View File

@ -0,0 +1,25 @@
// |jit-test| debug
// The GC can cope with old and new breakpoints at the same position.
// This is a regression test for a bug Bill McCloskey found just by looking at
// the source code. See bug 677386 comment 8. Here we're testing that the trap
// string is correctly marked. (The silly expression for the trap string is to
// ensure that it isn't constant-folded; it's harder to get a compile-time
// constant to be GC'd.)
var g = newGlobal('new-compartment');
g.eval("var d = 0;\n" +
"function f() { return 'ok'; }\n" +
"trap(f, 0, Array(17).join('\\n') + 'd++;');\n");
var dbg = new Debugger;
var gw = dbg.addDebuggee(g);
var fw = gw.getOwnPropertyDescriptor("f").value;
var bp = {hits: 0, hit: function (frame) { this.hits++; }};
fw.script.setBreakpoint(0, bp);
gc();
g.f();
assertEq(g.d, 1);
assertEq(bp.hits, 1);

View File

@ -814,7 +814,7 @@ JSCompartment::markBreakpointsIteratively(JSTracer *trc)
// Mark jsdbgapi state if any. But if we know the scriptObject, put off
// marking trap state until we know the scriptObject is live.
if (site->trapHandler &&
(!site->scriptObject || IsAboutToBeFinalized(cx, site->scriptObject)))
(!site->scriptObject || !IsAboutToBeFinalized(cx, site->scriptObject)))
{
if (site->trapClosure.isMarkable() &&
IsAboutToBeFinalized(cx, site->trapClosure.toGCThing()))