summaryrefslogtreecommitdiff
path: root/openmp
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2018-08-24 18:07:35 +0000
committerJonathan Peyton <jonathan.l.peyton@intel.com>2018-08-24 18:07:35 +0000
commit7b6f5e63dc8397451f858259d8d90271b6e6ba4a (patch)
tree4a1d7b0c666ebd2794aa0a3cf43e32e3b46885c0 /openmp
parent9367d3ecd7522369a57c57955811a00abf874527 (diff)
[OpenMP] Fix tasking bug for decreasing hot team nthreads
The __kmp_execute_tasks_template() function reads the task_team and current_task from the thread structure. There appears to be a pathological timing where the number of threads in the hot team decreases and so a thread is put in the pool via __kmp_free_thread(). It could be the case that: 1) A thread reads th_task_team into task_team local variables and is then interrupted by the OS 2) Master frees the thread and sets current task and task team to NULL 3) The thread reads current_task as NULL When this happens, current_task is dereferenced and a segfault occurs. This patch just checks for current_task to not be NULL as well. Differential Revision: https://reviews.llvm.org/D50651
Diffstat (limited to 'openmp')
-rw-r--r--openmp/runtime/src/kmp_tasking.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/openmp/runtime/src/kmp_tasking.cpp b/openmp/runtime/src/kmp_tasking.cpp
index d9220c5a2dc..e1b03f780b5 100644
--- a/openmp/runtime/src/kmp_tasking.cpp
+++ b/openmp/runtime/src/kmp_tasking.cpp
@@ -2469,7 +2469,7 @@ static inline int __kmp_execute_tasks_template(
KMP_DEBUG_ASSERT(__kmp_tasking_mode != tskm_immediate_exec);
KMP_DEBUG_ASSERT(thread == __kmp_threads[gtid]);
- if (task_team == NULL)
+ if (task_team == NULL || current_task == NULL)
return FALSE;
KA_TRACE(15, ("__kmp_execute_tasks_template(enter): T#%d final_spin=%d "