Skip to content
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

[libLLVM] Function scoped statics cause segfaults when main thread exits during compilation #132452

Open
patrick-rivos opened this issue Mar 21, 2025 · 0 comments

Comments

@patrick-rivos
Copy link
Contributor

Reproducer: https://github.com/patrick-rivos/llvm-function-scoped-statics

https://reviews.llvm.org/D129120 (and many other commits) removed uses of ManagedStatic and replaced the uses with a function-scoped static. This introduced subtle issues for multithreaded programs that dlopen libLLVM (eg. users of the jit).

Since static objects are destructed in reverse order of registration (alongside atexit handlers), multithreaded programs can encounter a situation where the main thread calls exit() and starts executing function-scoped static destructors. This can result in failed assertions or segfaults when compiling as the function-scoped static objects have been pulled out from under libLLVM.

Moving function-scoped statics back to ManagedStatic would fix this issue. Not sure if there are complexities with that approach.

Some relevant commits: ede6003 c4ccf60 ebbbd93

cc @nhaehnle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants