-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
runtime/src/coreclr/jit/ee_il_dll.cpp
Line 163 in 9f1dd1a
| static char CILJitBuff[sizeof(CILJit)]; |
Code in and around CILJitSingleton is returning a pointer in to a static char[] CILJitBuff, which in turn is returned from a placement new invocation. operator new is supposed to return memory aligned to __STDCPP_DEFAULT_NEW_ALIGNMENT__ which for linux x64 is 16.
When I link this code in CILJitBuff is not aligned. However, my build system takes liberties, so perhaps there is an out-of-band linker specification somewhere that tells the linker to align to 0 mod 16.
For gcc/clang, putting
__attribute__ ((__aligned__(__STDCPP_DEFAULT_NEW_ALIGNMENT__)))
on the declaration of CILJitBuf makes the alignment problem go away, but this is unlikely to port to MSVC,
Reproduction Steps
Compile with clang-14 -fsanitize=undefined and wait for the runtime checker to complain at the call to placement new.
Expected behavior
should return properly aligned data, and no observed runtime error
Actual behavior
run time error via -fsanitize=undefined and not suppressing all unaligned faults.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
/cc @AaronRob