[Openmp-commits] [openmp] r340632 - [OpenMP] Fix tasking bug for decreasing hot team nthreads

Jonathan Peyton via Openmp-commits openmp-commits at lists.llvm.org
Fri Aug 24 11:07:35 PDT 2018


Author: jlpeyton
Date: Fri Aug 24 11:07:35 2018
New Revision: 340632

URL: http://llvm.org/viewvc/llvm-project?rev=340632&view=rev
Log:
[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

Modified:
    openmp/trunk/runtime/src/kmp_tasking.cpp

Modified: openmp/trunk/runtime/src/kmp_tasking.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_tasking.cpp?rev=340632&r1=340631&r2=340632&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_tasking.cpp (original)
+++ openmp/trunk/runtime/src/kmp_tasking.cpp Fri Aug 24 11:07:35 2018
@@ -2469,7 +2469,7 @@ static inline int __kmp_execute_tasks_te
   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 "




More information about the Openmp-commits mailing list