Bug 454561 TM: Crash when JavaScript-Debugger is enabled [ @ jsd_lock ]
authortimeless@mozdev.org
Wed, 29 Oct 2008 11:06:01 +0100
changeset 21141 9ddc91081435f3804a8150571edc83a5de43f65d
parent 21139 05fc8ccb9d0f6b4fac134b1d0f6b5c4bcbdc6d2d
child 21142 c072c1a950ab28b0a6f3016140f91aa04243a747
push id3349
push usertimeless@mozdev.org
push dateFri, 31 Oct 2008 11:54:34 +0000
treeherdermozilla-central@c072c1a950ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs454561
milestone1.9.1b2pre
Bug 454561 TM: Crash when JavaScript-Debugger is enabled [ @ jsd_lock ] js_SynthesizeFrame needs to fill in all fields of JSInlineFrame. r=brendan
js/src/jstracer.cpp
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -2395,24 +2395,47 @@ js_SynthesizeFrame(JSContext* cx, const 
         JSStackFrame **disp = &cx->display[script->staticDepth];
         newifp->frame.displaySave = *disp;
         *disp = &newifp->frame;
     }
 #ifdef DEBUG
     newifp->frame.pcDisabledSave = 0;
 #endif
 
+    /*
+     * Note that cx->fp->script is still the caller's script; set the callee
+     * inline frame's idea of caller version from its version.
+     */
+    newifp->callerVersion = (JSVersion) cx->fp->script->version;
+
     cx->fp->regs = &newifp->callerRegs;
     cx->fp = &newifp->frame;
 
     if (fun->flags & JSFUN_HEAVYWEIGHT) {
+        /*
+         * Set hookData to null because the failure case for js_GetCallObject
+         * involves it calling the debugger hook.
+         */
+        newifp->hookData = NULL;
         if (!js_GetCallObject(cx, &newifp->frame, newifp->frame.scopeChain))
             return -1;
     }
 
+    /*
+     * If there's a call hook, invoke it to compute the hookData used by
+     * debuggers that cooperate with the interpreter.
+     */
+    JSInterpreterHook hook = cx->debugHooks->callHook;
+    if (hook) {
+        newifp->hookData = hook(cx, &newifp->frame, JS_TRUE, 0,
+                                cx->debugHooks->callHookData);
+    } else {
+        newifp->hookData = NULL;
+    }
+
     // FIXME? we must count stack slots from caller's operand stack up to (but not including)
     // callee's, including missing arguments. Could we shift everything down to the caller's
     // fp->slots (where vars start) and avoid some of the complexity?
     return (fi.s.spdist - cx->fp->down->script->nfixed) +
            ((fun->nargs > cx->fp->argc) ? fun->nargs - cx->fp->argc : 0) +
            script->nfixed;
 }