-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Issue]: Undefined behavior (misaligned allocation) for Semaphores in Thread #118
Comments
I think this is because Lines 80 to 82 in b8ba4cc
C++17 defines operator new with a different signature that allows alignment. If HeapObject implemented that I expect the Semaphore instances would be aligned correctly.
It might be best to remove the operator new impls for HeapObject instead. The default already is to use malloc so explicitly implementing via malloc seems like redundant code. |
Hi @LunNova. Internal ticket has been created to fix this issue. Thanks! |
Hi @LunNova, after some investigation, we have verified that the |
Can you publish the patch somewhere externally accessible so I can verify it? |
Sure, I can try to duplicate the PR to external. |
Here you go #128. A bit of explanation: we realized that due to how new is being handled, the alignment requirement has never really been satisfied at runtime. Instead of removing the "new" definition from HeapObject and risk things breaking down the line, we have decided to just remove the the memory alignment requirement after discussing with the original author of the code. Thanks! |
Confirmed that the error is gone on 21d7645 🎉 |
Problem Description
The three Semaphore instances created with operator new in Thread are created with a misaligned address, causing a undefined behavior error on library init if built with
-fsanitize=undefined
clr/rocclr/thread/thread.cpp
Lines 39 to 41 in b8ba4cc
I'm not sure why. Semaphore is marked alignas(64) and if I understand right operator new should handle this as of C++17.
Operating System
NixOS
CPU
7773
GPU
MI210
ROCm Version
ROCm 6.3.0
ROCm Component
clr
Steps to Reproduce
Build CLR with
-fsanitize=undefined
, dlopen libamdhip64The text was updated successfully, but these errors were encountered: