From f59bfe3b58920d90fd4c99dd3bd9ee901ea9236c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Pe=C3=B1acoba=20Veigas?= Date: Tue, 14 May 2024 14:47:00 +0000 Subject: [PATCH] Import a fix from upstream --- openmp/runtime/src/kmp_taskdeps.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openmp/runtime/src/kmp_taskdeps.cpp b/openmp/runtime/src/kmp_taskdeps.cpp index df8f917b9f24..48a0492962c2 100644 --- a/openmp/runtime/src/kmp_taskdeps.cpp +++ b/openmp/runtime/src/kmp_taskdeps.cpp @@ -1057,6 +1057,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) + KMP_YIELD(TRUE); + #if OMPT_SUPPORT __ompt_taskwait_dep_finish(current_task, taskwait_task_data); #endif /* OMPT_SUPPORT */