[Openmp-commits] [openmp] [openmp] Segfaults/assertion errors on certain omp statements after calling `omp_pause_resource_all(omp_pause_hard)` (PR #154204)

Haiyang He via Openmp-commits openmp-commits at lists.llvm.org
Thu Sep 4 22:49:25 PDT 2025


================
@@ -8343,6 +8345,10 @@ void __kmp_cleanup(void) {
 
   __kmpc_destroy_allocator(KMP_GTID_SHUTDOWN, __kmp_def_allocator);
   __kmp_def_allocator = omp_default_mem_alloc;
+#ifdef KMP_TDATA_GTID
+  /*reset __kmp_gtid to initial value*/
+  __kmp_gtid = KMP_GTID_DNE;
+#endif
----------------
haiyanghee wrote:

How do I know we are thread 0? Do I just check if `__kmp_gtid == 0` (as `__kmp_gtid` is declared as thread local storage) and if thats the case, I don't reset it?

I chose to reset `__kmp_gtid` to `KMP_GTID_DNE` because it is initialized to `KMP_GTID_DNE` in `kmp_global.cpp`, so I thought resetting to its default value was ok. 

Can you please point me how this can cause an issue in the code, so that I can understand the code base better?

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


More information about the Openmp-commits mailing list