[Mlir-commits] [mlir] fix a concurrent destruction issue for FallbackTypeIDResolver::registerImplicitTypeID due to function static variable (PR #85471)

Mehdi Amini llvmlistbot at llvm.org
Sat Mar 16 16:24:44 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 thread destructing it; construct the `registry`
+  // on the heap.
----------------
joker-eph wrote:

```suggestion
  // on the heap.
```

https://github.com/llvm/llvm-project/pull/85471


More information about the Mlir-commits mailing list