-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Clang's LLD is broken, again! #6126
Comments
Ah I remember now, that's the same thing as in mstorsjo/llvm-mingw#11 cc @adrpo |
Ouch! I guess I sort of expected some issues with allowing duplicate symbols when linking. |
This time it's a bug introduced somewhere around LLVM 8/9. |
- apply patch from: llvm/llvm-project@564481a - lld doesn't seem to hangs up anymore
- apply patch from: llvm/llvm-project@564481a - lld doesn't seem to hangs up anymore - fix CRLF to LF and update sums again
@HolyBlackCat Can you test again now? |
@lazka Works for me! |
Thanks! |
Unfortunately it's not fully fixed. |
@mati865 It sometimes hangs for me too, but not very often. |
Can confirm that ld.lld still hangs around once every three times it is invoked in an unpredictable fashion for me. |
@lazka This probably needs to be reopened. |
@adrpo What's the plan? It still hangs sometimes even with the patch, so the only option is to switch to static linking for LLD? |
FYI there were more fixes in LLVM master for hangs on Windows but I don't have time to find them. They will be included in LLVM 10 and hopefully fix it for good. |
@HolyBlackCat, I will have a look if is possible to static link just LLD. |
FTR here is stacktrace:
Probably a mingw-w64 bug. |
Here is a slightly better-symbolicated stack trace of the lld hang when dynamically linked to libLLVM.dll:
Now, as for why this happens... This is pretty much the same as https://devblogs.microsoft.com/oldnewthing/20120427-00/?p=7763, except for the part where it says "The only options are to hang or crash. I think I’ll crash"... this implementation decided to hang instead 😛 No really... Process shutdown terminates all other threads. One of those threads must have been holding the mutex around winpthreads' thread id table. Now when the remaining thread tries to call pthread_join from its global destructors, winpthread tries to acquire that mutex, and since it was never released it waits forever. The soluton? "The customer needs to restructure the program so that it either cleans up its thread pool work before the ExitProcess, or it can simply skip all thread pool operations when the reason for the DLL_PROCESS_DETACH is process termination." I'm not entirely sure how to do the latter... one hint I found is that the lpvReserved parameter will be non-NULL on DLL_PROCESS_DETACH if the process is exiting. @lhmouse any thoughts on whether this is a bug in mingw-w64, or in LLVM? |
An interesting comment on that MSDN page on DllMain:
I wonder if this is a suggestion to only call the destructors (_execute_onexit_table) if lpvReserved is NULL? |
On Linux, if a process calls On Windows, if a process calls Your suggestion to bypass destructors upon process exit doesn't seem correct to me, as such behavior is required by Itanium ABI. My opinion is that LLD should wait for worker threads explicitly before returning from |
I actually tried:
and that hangs as well. |
Never mind, the control flow in lld was weird, it didn't even get to my code. |
- use the patch from jeremyd2019 - remove the changes to patch 302 - update check sums
- use the patch from jeremyd2019 - remove the changes to patch 302 - update check sums - resolve ambigous wasm name by prefixing it with lld::
- use the patch from jeremyd2019 - remove the changes to patch 302 - update check sums - resolve ambigous wasm name by prefixing it with lld:: - bump pgkrel, remove !strip
- use the patch from jeremyd2019 - remove the changes to patch 302 - update check sums - resolve ambigous wasm name by prefixing it with lld:: - bump pgkrel, remove !strip Fixes msys2#6126, fixes msys2#7190
After the last update of the llvm packages (
9.0.0-3
), LDD no longer works.ld.lld.exe
hangs indefinitely. (It miraculously worked once for me, but no luck since then.)You can reproduce it simply by running
This closely resembles bug #5231 that was already fixed.
The text was updated successfully, but these errors were encountered: