[Mlir-commits] [mlir] fix a concurrent destruction issue for FallbackTypeIDResolver::registerImplicitTypeID due to function static variable (PR #85471)
Mehdi Amini
llvmlistbot at llvm.org
Fri Mar 15 16:35:39 PDT 2024
================
@@ -81,8 +81,11 @@ struct ImplicitTypeIDRegistry {
} // end namespace
TypeID detail::FallbackTypeIDResolver::registerImplicitTypeID(StringRef name) {
- static ImplicitTypeIDRegistry registry;
- return registry.lookupOrInsert(name);
+ // To prevent race conditions when one thread is accessing this `static`
+ // variable while other threads are destructing it; construct the `registry`
+ // on the heap.
----------------
joker-eph wrote:
> other threads are destructing it
You're using the plural here, but this destruction only happens when the program exits, and only a single thread (the main thread?) should actually call the destructor right?
Are you having a case when the program exit, the global destructors are called, but you still then will see a call to this registerImplicitTypeID?
https://github.com/llvm/llvm-project/pull/85471
More information about the Mlir-commits
mailing list