[Openmp-commits] [PATCH] D159324: [OpenMP] Fix a segment fault in __kmp_get_global_thread_id

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Aug 31 18:11:24 PDT 2023


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

improve comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159324

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
@@ -196,6 +196,12 @@
   if (i < 0)
     return i;
 
+  // other_threads[i] can be nullptr at this point because the corresponding
+  // thread could have already been destructed. It can happen when this function
+  // is called in end library routine.
+  if (!TCR_SYNC_PTR(other_threads[i]))
+    return i;
+
   /* dynamically updated stack window for uber threads to avoid get_specific
      call */
   if (!TCR_4(other_threads[i]->th.th_info.ds.ds_stackgrow)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159324.555216.patch
Type: text/x-patch
Size: 652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230901/b8a989f0/attachment-0001.bin>


More information about the Openmp-commits mailing list