[Openmp-commits] [openmp] [wip][openmp] Fix segfault when taskloop before taskgraph (PR #150877)

Josep Pinot via Openmp-commits openmp-commits at lists.llvm.org
Sun Jul 27 22:09:22 PDT 2025


https://github.com/jpinot created https://github.com/llvm/llvm-project/pull/150877

Fix a issue when taskloop whas encountered before a taskgraph clause, in that case the td_tdg_task_id was decrease without checking if it was inside a taskgraph.

>From 72f51014f1a6a23dba71085c80fe63bc2e59e262 Mon Sep 17 00:00:00 2001
From: jpinot <josep.pinot at bsc.es>
Date: Thu, 17 Jul 2025 12:22:01 +0200
Subject: [PATCH] [wip][openmp] Fix segfault when taskloop before taskgraph

Fix a issue when taskloop whas encountered before a taskgraph
clause, in that case the td_tdg_task_id was decrease without
checking if it was inside a taskgraph.
---
 openmp/runtime/src/kmp_tasking.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp
index e4d92a78fd6b9..f4e5107627b73 100644
--- a/openmp/runtime/src/kmp_tasking.cpp
+++ b/openmp/runtime/src/kmp_tasking.cpp
@@ -4952,7 +4952,8 @@ static void __kmp_taskloop(ident_t *loc, int gtid, kmp_task_t *task, int if_val,
   }
 
 #if OMPX_TASKGRAPH
-  KMP_ATOMIC_DEC(&__kmp_tdg_task_id);
+  if (taskdata->is_taskgraph)
+    KMP_ATOMIC_DEC(&__kmp_tdg_task_id);
 #endif
   // =========================================================================
   // calculate loop parameters



More information about the Openmp-commits mailing list