The default bug view has changed. See this FAQ.

Poison JSScripts when freed to get more crash data

RESOLVED FIXED in mozilla8

Status

()

Core
JavaScript Engine
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: billm, Assigned: billm)

Tracking

(Blocks: 1 bug)

unspecified
mozilla8
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [inbound])

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

6 years ago
Created attachment 545522 [details] [diff] [review]
patch

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+
(Assignee)

Comment 2

6 years ago
Created attachment 545679 [details] [diff] [review]
new patch

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+
(Assignee)

Comment 4

6 years ago
OK, thanks Dave. I'll make sure it works before pushing.
(Assignee)

Updated

6 years ago
Whiteboard: [inbound]
http://hg.mozilla.org/mozilla-central/rev/44f0f4395d6a
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla8
You need to log in before you can comment on or make changes to this bug.