Page MenuHomeFreeBSD

libcxxrt: add padding in __cxa_allocate_* to fix alignment
ClosedPublic

Authored by emaste on Jul 21 2016, 2:31 PM.

Details

Summary

Prior to the addition of the referenceCount in __cxa_exception the unwindHeader was at offset 0x50, and it requires 16-byte alignment. Add padding in the same location that it will appear in libstdc++.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

emaste retitled this revision from to libcxxrt: add padding to __cxa_exception to fix alignment.Jul 21 2016, 2:31 PM
emaste updated this object.
emaste edited the test plan for this revision. (Show Details)
emaste added reviewers: dim, theraven, ed.
emaste added a subscriber: gjb.
emaste updated this revision to Diff 18631.

Here's a libstdc++ bug for a nearly identical issue issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38732
See specifically comment 13: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38732#c13

emaste retitled this revision from libcxxrt: add padding to __cxa_exception to fix alignment to libcxxrt: add padding in __cxa_allocate_* to fix alignment.EditedJul 21 2016, 4:06 PM
emaste updated this revision to Diff 18633.

Avoid changing the __cxa_exception ABI in 11.

The addition of the referenceCount to __cxa_allocate_exception put the unwindHeader at offset 0x58, but it requires 16-byte alignment. In order to avoid changing the broken __cxa_exception ABI (and thus breaking its consumers), add explicit padding in the allocation routins (and account for it when freeing).

emaste added inline comments.Jul 21 2016, 5:43 PM
contrib/libcxxrt/exception.cc
576–582 ↗(On Diff #18633)

Should this be // comments instead?

dim edited edge metadata.Jul 21 2016, 6:02 PM
dim accepted this revision.

LGTM. This looks like the least intrusive solution.

contrib/libcxxrt/exception.cc
576–582 ↗(On Diff #18633)

Not necessary, for instance the block below it uses /**, which appears to be used for longer comments (though not very consistently).

This revision is now accepted and ready to land.Jul 21 2016, 6:02 PM
This revision was automatically updated to reflect the committed changes.
theraven added inline comments.Jul 22 2016, 7:11 AM
head/contrib/libcxxrt/exception.cc
583

It would be nice if this could be computed with offsetof(), sizeof() and alignof(), rather than being hard-coded.