[Openmp-commits] [PATCH] D159369: [OpenMP] Fix a wrong assertion in `__kmp_get_global_thread_id`

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Wed Sep 6 09:21:55 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGff5c7261ef01: [OpenMP] Fix a wrong assertion in `__kmp_get_global_thread_id` (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159369/new/

https://reviews.llvm.org/D159369

Files:
  openmp/runtime/src/kmp_runtime.cpp


Index: openmp/runtime/src/kmp_runtime.cpp
===================================================================
--- openmp/runtime/src/kmp_runtime.cpp
+++ openmp/runtime/src/kmp_runtime.cpp
@@ -178,7 +178,12 @@
       if (stack_diff <= stack_size) {
         /* The only way we can be closer than the allocated */
         /* stack size is if we are running on this thread. */
-        KMP_DEBUG_ASSERT(__kmp_gtid_get_specific() == i);
+        // __kmp_gtid_get_specific can return negative value because this
+        // function can be called by thread destructor. However, before the
+        // thread destructor is called, the value of the corresponding
+        // thread-specific data will be reset to NULL.
+        KMP_DEBUG_ASSERT(__kmp_gtid_get_specific() < 0 ||
+                         __kmp_gtid_get_specific() == i);
         return i;
       }
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159369.556049.patch
Type: text/x-patch
Size: 867 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230906/48253616/attachment.bin>


More information about the Openmp-commits mailing list