[Openmp-commits] [openmp] [OpenMP] Fix node destruction race in __kmpc_omp_taskwait_deps_51 (PR #86130)

Ulrich Weigand via Openmp-commits openmp-commits at lists.llvm.org
Wed Mar 27 07:50:14 PDT 2024


================
@@ -1030,6 +1030,12 @@ void __kmpc_omp_taskwait_deps_51(ident_t *loc_ref, kmp_int32 gtid,
                        __kmp_task_stealing_constraint);
   }
 
+  // Wait until the last __kmp_release_deps is finished before we free the
+  // current stack frame holding the "node" variable; once its nrefs count
+  // reaches 1, we're sure nobody else can try to reference it again.
+  while (node.dn.nrefs > 1)
----------------
uweigand wrote:

An alternative solution would be to just not use a stack-allocated node, but allocate it on the heap like everywhere else.  Then there'd still be a race which thread would be the one to free it, but that race would be harmless ...  Let me know if you'd like me to try this (or any other) approach.

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


More information about the Openmp-commits mailing list