Closed Bug 671113 Opened 13 years ago Closed 13 years ago

Poison JSScripts when freed to get more crash data

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla8

People

(Reporter: billm, Assigned: billm)

References

Details

(Whiteboard: [inbound])

Attachments

(1 file, 1 obsolete file)

Attached patch patch (obsolete) — Splinter Review
This is a follow-up on bug 670702. This patch poisons scripts when they're freed. It also tries to verify that the circular list of scripts that each compartment keeps is valid. It adds a cookie field to the beginning and middle of each script, and checks that the cookies have the right values. I'm not exactly sure what we'll get out of this, but hopefully it will give us something useful.
Attachment #545522 - Flags: review?(dmandelin)
Comment on attachment 545522 [details] [diff] [review]
patch

Review of attachment 545522 [details] [diff] [review]:
-----------------------------------------------------------------

A name like js_CheckCompartmentScripts is probably better than js_AssertScriptListValid, since it's checking the validity of the scripts in the list, not the lists itself, but I think I don't care that much about a single diagnostic function. Now that I mention that, it should js::Whatever instead of js_Whatever, though.
Attachment #545522 - Flags: review?(dmandelin) → review+
Attached patch new patchSplinter Review
Sorry for the re-review. The previous patch timed out on tryserver in jstests. I guess that iterating over every script every time we make a new script is too expensive. So now that traversal only happens during a GC. I also added some new instrumentation to js_TraceScript.
Assignee: general → wmccloskey
Attachment #545522 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #545679 - Flags: review?(dmandelin)
Comment on attachment 545679 [details] [diff] [review]
new patch

Review of attachment 545679 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/jsscript.cpp
@@ +1408,5 @@
> +CheckScript(JSScript *script, JSScript *prev)
> +{
> +    if (script->cookie1 != JS_SCRIPT_COOKIE || script->cookie2 != JS_SCRIPT_COOKIE) {
> +        volatile char dbg1[sizeof(JSScript)], dbg2[sizeof(JSScript)];
> +        memcpy((void *)dbg1, script, sizeof(JSScript));

I suspect the optimizer will optimize away the |memcpy|s. I just tried it in an example program in MSVC10 and it did. You could test it easily enough and see if it does in this case.

In the past, I wrote my own memcpy with a volatile destination parameter, and that worked.
Attachment #545679 - Flags: review?(dmandelin) → review+
OK, thanks Dave. I'll make sure it works before pushing.
Whiteboard: [inbound]
http://hg.mozilla.org/mozilla-central/rev/44f0f4395d6a
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla8
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: