Closed Bug 747870 Opened 12 years ago Closed 12 years ago

Unaligned access in XPCCallContext::XPCCallContext

Categories

(Core :: XPConnect, defect)

Sun
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla15

People

(Reporter: glandium, Assigned: glandium)

References

()

Details

Attachments

(1 file)

I got a report about Iceweasel crashing at startup on sparc. The relevant part of the backtrace is here:
#0  XPCCallContext::XPCCallContext (this=0xffff566c, callerLanguage=XPCContext::LANG_JS, cx=0xf7924340, callBeginRequest=0, obj=0xf0c9d900, 
    flattenedJSObject=0xf0c9d900, wrapper=0x0, tearOff=0x0)
    at js/xpconnect/src/XPCCallContext.cpp:83
#1  0xf6deef30 in XPCLazyCallContext::GetXPCCallContext (this=0xffff5648)
    at js/xpconnect/src/xpcprivate.h:1335

The problem comes from using the placement new operator with an array of char, which is not correctly aligned for the XPCCallContext class.

Thanks to Jurij Smakov for tracking down the root cause.
Attachment #617439 - Flags: review?(bobbyholley+bmo)
Comment on attachment 617439 [details] [diff] [review]
Properly align XPCLazyCallContext::mData

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

::: js/xpconnect/src/xpcprivate.h
@@ +1315,1 @@
>                                             mCallBeginRequest == CALL_BEGINREQUEST,

Fix indentation somehow, please.
Comment on attachment 617439 [details] [diff] [review]
Properly align XPCLazyCallContext::mData

This won't cause any extra code to be run on XPCLazyCallContext instantiation, right? These things need to be super fast, at least until the new DOM bindings are done.

r=bholley with the indentation fixed.
Attachment #617439 - Flags: review?(bobbyholley+bmo) → review+
No, it's just a POD type with the right alignment.
(In reply to Ms2ger from comment #2)
> Comment on attachment 617439 [details] [diff] [review]
> Properly align XPCLazyCallContext::mData
> 
> Review of attachment 617439 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: js/xpconnect/src/xpcprivate.h
> @@ +1315,1 @@
> >                                             mCallBeginRequest == CALL_BEGINREQUEST,
> 
> Fix indentation somehow, please.

As indenting would make that line you quote go overboard, what style would you prefer?
mCcxToDestroy = mCcx = new (mData.addr())
    XPCCallContext(mCallerLanguage, (...)

mCcxToDestroy = mCcx =
    new (mData.addr())
        XPCCallContext(mCallerLanguage, (...)

char *data = mData.addr();
mCcxToDestroy = mCcx =
    new (data) XPCCallContext(mCallerLanguage, (...)

other ?

(The latter case allowing the current indentation being kept)
(In reply to Mike Hommey [:glandium] from comment #5)
> char *data = mData.addr();

XPCCallContext *data, even.
(In reply to Mike Hommey [:glandium] from comment #5)
> (The latter case allowing the current indentation being kept)

SGTM.
https://hg.mozilla.org/mozilla-central/rev/77e68aa8f24c
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: