Closed Bug 471716 Opened 16 years ago Closed 15 years ago

jsobj.cpp DEBUG / [@ js_DumpObject] crash on JSFunction with null proto

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: andrew, Assigned: andrew)

Details

(Keywords: crash, fixed1.9.1, Whiteboard: fixed-in-tracemonkey)

Crash Data

Attachments

(1 file, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5
Build Identifier: mozilla-central

When calling JS_DumpObject() on a JSFunction with a null proto, it crashes in fprintf() because proto is passed as an argument. Attaching a patch which simply checks for proto prior to printing and also fixes an "#if DEBUG" to be "#ifdef DEBUG" to be compatible with some other uses of -DDEBUG (and to be consistent with the rest of the file).

Reproducible: Always
Attached patch Proposed patch (obsolete) — Splinter Review
Did you want to ask for review on the attached patch?
Attachment #354975 - Flags: review?(andrew)
Comment on attachment 354975 [details] [diff] [review]
Proposed patch

You have to ask for a module owner/peer to review this.
Attachment #354975 - Flags: review?(andrew) → review?(brendan)
Attachment #354975 - Flags: review?(brendan) → review?(jorendorff)
Comment on attachment 354975 [details] [diff] [review]
Proposed patch

Overbrace multiline if/then/else parts. With that nit, r=me but I'd rather jorendorff deal with this (on vacation, js_DumpObject was his baby -- it's very helpful, btw).

/be
This isn't a trivial bug: things like this have hit me in the middle of a long, complex, debugging session and have cost me lots of lost time.

One nit in the description of the bug: the problem isn't passing NULL to a '%p' printf directive; the problem is that we also attempt to pass the name of the proto's class (via STOBJ_GET_CLASS(proto)->name) and attempting to get the class out of proto is what crashes.
Assignee: general → andrew
Severity: trivial → normal
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
I meant in general that proto was being used as an argument while null :) IIRC glibc printf handles null values, but I'm not sitting on top of glibc, so either one crashes for me.
Attachment #354975 - Attachment is obsolete: true
Attachment #354981 - Flags: review?(jorendorff)
Attachment #354975 - Flags: review?(jorendorff)
Comment on attachment 354981 [details] [diff] [review]
Update for Brendan's nit

Thanks!
Attachment #354981 - Flags: review?(jorendorff) → review+
NPOTB, important to avoid unexpected loss of debugging state.

/be
Flags: wanted1.9.1?
Flags: wanted1.9.1? → wanted1.9.1+
http://hg.mozilla.org/mozilla-central/rev/139ce7cb0fc1
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Summary: jsobj.cpp DEBUG / js_DumpObject crash on JSFunction with null proto → jsobj.cpp DEBUG / [@ js_DumpObject] crash on JSFunction with null proto
Keywords: crash
Flags: in-testsuite-
Crash Signature: [@ js_DumpObject]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: