Closed Bug 963738 Opened 11 years ago Closed 10 years ago

Handle Arrays in the analysis

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29
Tracking Status
firefox40 --- fixed

People

(Reporter: sfink, Assigned: sfink)

References

Details

Attachments

(5 files, 2 obsolete files)

Value[] foo = { ... }; is currently being entirely ignored, because it shows up in the analysis as an "Array", and the analysis only knows "Pointer" and "CSU" (Class/Struct/Union.)
Attached patch Handle Arrays in the analysis (deleted) — Splinter Review
Large bump in the number of hazards.
Attachment #8365276 - Flags: review?(terrence)
Group: core-security
Comment on attachment 8365276 [details] [diff] [review] Handle Arrays in the analysis Review of attachment 8365276 [details] [diff] [review]: ----------------------------------------------------------------- r=me
Attachment #8365276 - Flags: review?(terrence) → review+
Blocks: 898606
I've verified that all identified hazards are false positives or in tests, so opening up.
Group: core-security
Attached patch hazards_array-v0.diff (deleted) — Splinter Review
This is all the low-hanging fruit. I have one other largish patch for nsJSNPRuntime, which I've split off for gecko peer review. There are three remaining hazards which are all false positives for which simple code reorganization will not work. We'll need to think of some other mechanism(s) for those.
Attachment #8366919 - Flags: review?(jcoppeard)
Attached patch hazard_npapi-v0.diff (obsolete) (deleted) — Splinter Review
Will flag this for review when the try run is green.
Comment on attachment 8366950 [details] [diff] [review] hazard_npapi-v0.diff Review of attachment 8366950 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/plugins/base/nsJSNPRuntime.cpp @@ -634,5 @@ > } else { > fv = OBJECT_TO_JSVAL(npjsobj->mJSObj); > } > > - JS::Value jsargs_buf[8]; Could we use AutoValueVector here? It looks like it will handle allocating the elements possibly-inline for us.
Comment on attachment 8366919 [details] [diff] [review] hazards_array-v0.diff Review of attachment 8366919 [details] [diff] [review]: ----------------------------------------------------------------- This all looks good.
Attachment #8366919 - Flags: review?(jcoppeard) → review+
I noticed the try run was failing. It turns out this was caused by the fix for bug 962256, so I kicked off a new one without that patch: https://tbpl.mozilla.org/?tree=Try&rev=916abaa43b1f
Attached patch hazard_npapi-v1.diff (obsolete) (deleted) — Splinter Review
Great idea, Jon! The default inline count is even 8, so we don't even need to pass through new template args to get identical behavior.
Attachment #8367698 - Flags: review?(benjamin)
Attached patch hazard_npapi-v1.diff (deleted) — Splinter Review
This time with more qreffing.
Attachment #8366950 - Attachment is obsolete: true
Attachment #8367698 - Attachment is obsolete: true
Attachment #8367698 - Flags: review?(benjamin)
Attachment #8367709 - Flags: review?(benjamin)
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Whiteboard: [leave open]
Attachment #8367709 - Flags: review?(benjamin) → review+
And we're good now.
Status: REOPENED → RESOLVED
Closed: 11 years ago11 years ago
Resolution: --- → FIXED
Whoops, this should never have been closed. The actual hazards have been fixed, but the analysis patch never landed because there were some nuisance false positives left.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
When adding in stack arrays to the analysis, I hit a false positive that looked something like this: GCPointer localArray[10]; GCPointer *data = nullptr; localArray[3] = JS::NewGCThing(...); if (...) data = localArray; canGC(); if (data != localArray) free(data); The idea is that you get a fixed-size buffer on the stack to store a set of GC pointers, and if you need more space it gets malloced. The analysis sees this as a hazard, because 'localArray' is live after the canGC() call due to its use in the |if (data != localArray)| call. But its *contents* are never examined, so this is a false positive -- if a GC thing in localArray were moved, nothing would ever see it. So I'd like to allow this use by saying that Assume(...var...) doesn't extend var's live range, unless it's in the form of Assume(...*var...). I believe that this might also help with situations like: JSObject *raw = ...; RootedObject rooted(cx, raw); canGC(); if (rooted != raw) { ...do expensive fixup stuff... } though perhaps the fixup stuff will always end up using 'raw' in a way that extends the live range? I haven't looked at examples. (The attached patch does not ignore any Assign or Call that uses the variable without dereferencing it.)
Attachment #8585561 - Flags: review?(bhackett1024)
Attachment #8585561 - Flags: review?(bhackett1024) → review+
Attached patch Annotate XPCNativeMember (deleted) — Splinter Review
Ok, now that I'm all educated on interning (pinning) and understand that this is not a hazard because of the interning (pinning), I agree that this should just be annotated away. The most precise annotation I could come up with is for XPCNativeMember (since I didn't want to annotate away jsid entirely, even though an argument could be made for it.) But it's a weird annotation. And I hope to stop pinning these jsids, in which case we'll need to root here after all. But that will also require fixing NPIdentifier, so I stuck in an annotation for it at the same time. (The analysis currently doesn't see it because the compiler only sees it as a void*.) That way, I'll remember to remove both annotations at the same time.
Attachment #8588745 - Flags: review?(terrence)
Attachment #8588745 - Flags: review?(terrence) → review+
Whiteboard: [leave open]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: