[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:15:46 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG35fdf8d70329: [OpenMP] Fix a segment fault in __kmp_get_global_thread_id (authored by tianshilei1992).

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


More information about the Openmp-commits mailing list