Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix __cxa_exception alignment under libstdc++ with gcc
Summary: Fixes: facebook#2359. In the debugger, I observed calls to `__cxa_allocate_exception` with size `n` calling `malloc` with size `128 + n`. I compared 128 with `sizeof(__cxa_refcounted_exception)` in our replica, which was only 120. So there must have been some difference between the replica and the original. But there was no difference between the fields in `__cxa_refcounted_exception` or in `__cxa_exception`; so the only remaining place to look was in `_Unwind_Exception`. We do not have a replica of `_Unwind_Exception` since `unwind.h` is always available, but it might be from either libgcc or from libunwind, so the difference must have been between these two. * The type `_Unwind_Exception` is marked in libgcc as being fully aligned: https://github.com/gcc-mirror/gcc/blob/releases/gcc-14.2.0/libgcc/unwind-generic.h#L106. * Likewise in llvm-unwind: https://github.com/llvm/llvm-project/blob/llvmorg-19.1.7/libunwind/include/unwind_itanium.h#L41. * It is used without explicit alignment in libstdc++ authoritative `__cxa_exception`: https://github.com/gcc-mirror/gcc/blob/releases/gcc-14.2.0/libstdc%2B%2B-v3/libsupc%2B%2B/unwind-cxx.h#L97. * The type may not be marked as being fully aligned in upstream libunwind: https://github.com/libunwind/libunwind/blob/v1.8.1/include/unwind.h#L80. * In our replica of `__cxa_exception`, we must mark the field as being fully aligned in case the replica uses a definition of the type which is not marked as being fully aligned. Differential Revision: D68391229
- Loading branch information