Unaligned access in XPCCallContext::XPCCallContext

RESOLVED FIXED in mozilla15

Status

()

Core
XPConnect
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: glandium, Assigned: glandium)

Tracking

Trunk
mozilla15
Sun
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Assignee)

Description

5 years ago
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.
(Assignee)

Comment 1

5 years ago
Created attachment 617439 [details] [diff] [review]
Properly align XPCLazyCallContext::mData
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+
(Assignee)

Comment 4

5 years ago
No, it's just a POD type with the right alignment.
(Assignee)

Comment 5

5 years ago
(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)
(Assignee)

Comment 6

5 years ago
(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.
(Assignee)

Comment 8

5 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/77e68aa8f24c
Target Milestone: --- → mozilla15
https://hg.mozilla.org/mozilla-central/rev/77e68aa8f24c
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.