In 32 bit builds on a 64 bit system std::malloc does not return correctly aligned memory. This leads to undefined behavior.
This patch switches to using posix_memalign to allocate correctly aligned memory instead.
Differential D25417
[libcxxabi] Fix alignment of allocated exceptions in 32 bit builds EricWF on Oct 9 2016, 9:54 PM. Authored by
Details In 32 bit builds on a 64 bit system std::malloc does not return correctly aligned memory. This leads to undefined behavior. This patch switches to using posix_memalign to allocate correctly aligned memory instead.
Diff Detail Event TimelineComment Actions I thought we had gotten this merged already. Oops. LGTM with the minor tweak for windows.
Comment Actions
I'll commit after testing on OS X. Comment Actions I ran into some test failures on OS X while attempting to commit this. The unwind.h header provided on OS X hasn't upstreamed the libunwind fix from r276215, meaning __cxa_exception is still under-aligned and therefore so is the exception. I'll commit this in the next day or two after dealing with the apple bug. |
Given that libc++abi has some Windows support and usage (e.g. MinGW), we should change this to: