[Openmp-commits] [PATCH] D50651: [OpenMP] Fix tasking bug for decreasing hot team nthreads

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Aug 13 10:48:03 PDT 2018


jlpeyton created this revision.
jlpeyton added reviewers: AndreyChurbanov, tlwilmar, hbae, omalyshe.
jlpeyton added a project: OpenMP.
Herald added a subscriber: guansong.

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 where
first: a thread reads `th_task_team` into `task_team` local variables

  and is then interrupted by the OS

second: the master free's the thread and sets the current task and task team to `NULL`
third: 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.


Repository:
  rOMP OpenMP

https://reviews.llvm.org/D50651

Files:
  runtime/src/kmp_tasking.cpp


Index: runtime/src/kmp_tasking.cpp
===================================================================
--- runtime/src/kmp_tasking.cpp
+++ runtime/src/kmp_tasking.cpp
@@ -2465,7 +2465,7 @@
   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 "


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50651.160397.patch
Type: text/x-patch
Size: 480 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20180813/ce69852c/attachment-0001.bin>


More information about the Openmp-commits mailing list