-
-
Notifications
You must be signed in to change notification settings - Fork 470
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
Reference counting of std::shared_ptr is non-atomic when using the mold linker #1286
Comments
Thank you for your report. This is a very difficult issue and arguably a bug in glibc rather than the linker. At least the code is very fragile as it depends on when a weak symbol is resolved. Even with GNU ld, if you compile your main executable with Let me think more about how to fix this. By the way, how did you find this problem? |
Please try again with git head. |
Thanks for the reply and fix!
We have experienced several occasional memory issues, like heap-use-after-free on the control block of Interestingly, at the beginning we fixed this bug by linking against
I'm not a toolchain guy. Is there any related discussion on this problem? Maybe I can have more understanding on this. |
I wrote the explanation of the issue as the commit message, so you may want to read it first if you want to understand it more. Feel free to ask any questions! |
I think this is worth making a new release. I'll be releasing mold 2.32.1 soon. |
First of all, thanks for this great linker. It's blazing fast and saves me a lot of build time.
My environment:
Simplified code to reproduce this issue:
Build & run
Some facts:
shared_ptr
is atomic only if it's in a multiple threaded process. Refer to here__gthread_active_p
, which utilizes a weak reference to__pthread_key_create
fromlibpthread
. Refer to here__gthread_active_p
returns false.ld.bfd
,ld.gold
andmold
2.1.0 is OK.Thanks in advance.
The text was updated successfully, but these errors were encountered: