Closed
Bug 822425
Opened 12 years ago
Closed 11 years ago
Expose assertSameCompartment outside the JS engine
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla28
People
(Reporter: mccr8, Assigned: bholley)
References
Details
(Whiteboard: [qa-])
Attachments
(1 file, 1 obsolete file)
1.81 KB,
patch
|
mccr8
:
review+
|
Details | Diff | Splinter Review |
It would be nice if we had a friend API for this, so XPConnect can use it instead of making ad hoc compartment checking assertions. Probably we only need object and maybe string.
Then I can file a followup to actually use it.
Assignee | ||
Comment 1•11 years ago
|
||
Only the first one will benefit from our Nightly-mode compartment assertions,
but both are useful for consistency.
Attachment #814877 -
Flags: review?(wmccloskey)
Assignee | ||
Updated•11 years ago
|
Blocks: CVE-2014-1479
Reporter | ||
Comment 2•11 years ago
|
||
In the header file, the one with a context shouldn't be turned into an empty function in a non-debug build, or we won't get release mode assertions. In the cpp file, you should guard the object-object one inside #ifdef DEBUG.
Assignee | ||
Comment 3•11 years ago
|
||
(In reply to Andrew McCreight [:mccr8] from comment #2)
> In the header file, the one with a context shouldn't be turned into an empty
> function in a non-debug build, or we won't get release mode assertions. In
> the cpp file, you should guard the object-object one inside #ifdef DEBUG.
Oh hm, that's a good point. It's a shame that this means that we'll have a performance penalty in release builds regardless, but it's probably negligible. And anyway, the once we fold mozjs.dll into libxul on windows, LTO should take care of it.
Assignee | ||
Comment 4•11 years ago
|
||
Attachment #814877 -
Attachment is obsolete: true
Attachment #814877 -
Flags: review?(wmccloskey)
Attachment #814898 -
Flags: review?(continuation)
Reporter | ||
Comment 5•11 years ago
|
||
Comment on attachment 814898 [details] [diff] [review]
Expose a few simple compartment assertions in jsfriendapi. v2
Review of attachment 814898 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/src/jsfriendapi.h
@@ +483,5 @@
> JS_FRIEND_API(JSObject *)
> GetGlobalForObjectCrossCompartment(JSObject *obj);
>
> +JS_FRIEND_API(void)
> +AssertSameCompartment(JSContext *cx, JSObject *obj);
If you wanted to avoid the call overhead in release builds, you could wrap this in something like |#ifdef JS_CRASH_DIAGNOSTICS or DEBUG|, otherwise define it as empty. That's what the JS engine uses, and maybe the CRASH flag is defined for browser code, too? If you do that, it would be good to check.
@@ +487,5 @@
> +AssertSameCompartment(JSContext *cx, JSObject *obj);
> +
> +#ifdef DEBUG
> +JS_FRIEND_API(void)
> +AssertSameCompartment(JSObject *objA, JSObject *objB);
I'll assume you have a use-case for this form. I don't think the JS engine has any variants without a cx involved. Instead, it has (cx, obj, obj) etc.
Attachment #814898 -
Flags: review?(continuation) → review+
Comment 6•11 years ago
|
||
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
Updated•11 years ago
|
Assignee: general → bobbyholley+bmo
Comment 7•11 years ago
|
||
status-firefox27:
--- → fixed
status-firefox28:
--- → fixed
Updated•11 years ago
|
Whiteboard: [qa-]
Comment 8•11 years ago
|
||
You need to log in
before you can comment on or make changes to this bug.
Description
•