Closed Bug 609687 Opened 14 years ago Closed 14 years ago

crash jsd single stepping [@ jsd_FunctionCallHook]

Categories

(Core :: JavaScript Engine, defect)

x86
Windows 7
defect
Not set
critical

Tracking

()

RESOLVED FIXED
Tracking Status
blocking2.0 --- beta8+

People

(Reporter: johnjbarton, Assigned: timeless)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file, 1 obsolete file)

Blocks: 609663

            Mozilla/5.0 (Windows NT 6.1; rv:2.0b8pre) Gecko/20101104 Firefox/4.0b8pre
Hmm. I also have Chromebug and FBTest running
With just FBTrace and Firebug I don't crash
No longer blocks: 609663
I am seeing this too. I am only using Firebug1.7, no Chromebug or FBTest.

What I see happening, going backwards:

 - jsd_FunctionCallHook is passed a NULL 'closure' arg.

 - the interpreter's ScriptEpilogue invokes jsd_FunctionCallHook with this guard:

    if (hook && fp->hasHookData() && !fp->isExecuteFrame())
        hook(cx, fp, JS_FALSE, &ok, fp->hookData());

 - hasHookData() is testing the frame's JSFRAME_HAS_HOOK_DATA flag, not the hook data itself (which is why that guard passes it)

 - earlier, setHookData is called to set a NULL hookData_

 - the NULL comes from the interpreter's ScriptProlog:

    JSInterpreterHook hook = cx->debugHooks->callHook;
    if (JS_UNLIKELY(hook != NULL) && !fp->isExecuteFrame())
        fp->setHookData(hook(cx, fp, JS_TRUE, 0, cx->debugHooks->callHookData));

 - all of this is triggered when I set a breakpoint on a for loop and then single-step.

The intent here is that the entry hook gets to decide whether the exit hook is called. Which suggests to me that the unconditional call to fp->setHookData is wrong. I'll chase it back through hg history, but hopefully someone knowledgeable will chip in.
blocking2.0: --- → ?
Component: General → JavaScript Debugging APIs
Product: Firefox → Core
QA Contact: general → jsd
Someone broke the js api design.

http://mxr.mozilla.org/mozilla1.8/source/js/src/jsinterp.c#1367

1365     /* call the hook if present */
1366     if (hook && (native || script))
1367         hookData = hook(cx, &frame, JS_TRUE, 0, cx->runtime->callHookData);

1369     /* Call the function, either a native method or an interpreted script. ....
1413 out:
1414     if (hookData) {
1415         hook = cx->runtime->callHook;
1416         if (hook)
1417             hook(cx, &frame, JS_FALSE, &ok, hookData);
1418     }

The design is such that the return from hook() is either a closure or null. If it's null, then the hook on the other side is *not* called.
Assignee: nobody → general
Component: JavaScript Debugging APIs → JavaScript Engine
QA Contact: jsd → general
Assignee: general → timeless
Status: NEW → ASSIGNED
Attachment #490038 - Flags: review?(brendan)
An alternative would be to make setHookData clear the FRAME_HAS_HOOK_DATA flag when NULL is passed in, and leave everything else alone.

I'm not sure why the flag exists, if it's purely redundant with !!hookData_. I guess it's just mimicking several other fields, and for some of those, NULL must be a valid value?
Comment on attachment 490038 [details] [diff] [review]
restore jsapi behavior antebellum

Luke, would you be willing to review and follow up on the frame flag issue Steve pointed out? Thanks,

/be
Attachment #490038 - Flags: review?(brendan) → review?(lw)
Severity: normal → critical
Summary: crash jsd single stepping jsd_FunctionCallHook → crash jsd single stepping [@ jsd_FunctionCallHook]
(In reply to comment #7)
The flag allows us to leave hookData_ uninitialized when pushing a stack frame, as part of the general "make calls fast" effort.
Attachment #490038 - Flags: review?(lw) → review+
Attached patch for commitSplinter Review
luke/et al: please land according to whatever process is being used

I'm at a conference for the week...
Attachment #490038 - Attachment is obsolete: true
Attachment #490875 - Flags: review+
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/22273789b140
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
blocking2.0: ? → beta8+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: