[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
Fri Sep 1 11:11:29 PDT 2023


tianshilei1992 updated this revision to Diff 555444.
tianshilei1992 added a comment.

fix comment


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 KMP_GTID_DNE 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.555444.patch
Type: text/x-patch
Size: 865 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230901/907c750b/attachment-0001.bin>


More information about the Openmp-commits mailing list