diff options
author | Jonas Hahnfeld <Hahnfeld@itc.rwth-aachen.de> | 2016-01-28 10:39:45 +0000 |
---|---|---|
committer | Jonas Hahnfeld <Hahnfeld@itc.rwth-aachen.de> | 2016-01-28 10:39:45 +0000 |
commit | dbf627dbd49bf58c94b45f5f98605b2a951f5fef (patch) | |
tree | 4005f33794029b7339609e0a3f553676954ff8c2 | |
parent | 7a964feccbc3b366223a1f0b4c1f51c7e4a1d695 (diff) | |
download | bcm5719-llvm-dbf627dbd49bf58c94b45f5f98605b2a951f5fef.tar.gz bcm5719-llvm-dbf627dbd49bf58c94b45f5f98605b2a951f5fef.zip |
[OMPT] Avoid SEGV when a worker thread needs its parallel id behind the barrier
When the code behind the barrier is executed, the master thread may have
already resumed execution. That's why we cannot safely assume that *pteam
is not yet freed.
This has been introduced by r258866.
llvm-svn: 259037
-rw-r--r-- | openmp/runtime/src/kmp_runtime.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/openmp/runtime/src/kmp_runtime.c b/openmp/runtime/src/kmp_runtime.c index fda7014a43c..2f7d3e960c7 100644 --- a/openmp/runtime/src/kmp_runtime.c +++ b/openmp/runtime/src/kmp_runtime.c @@ -5504,8 +5504,10 @@ __kmp_launch_thread( kmp_info_t *this_thr ) if ( TCR_SYNC_PTR(*pteam) && !TCR_4(__kmp_global.g.g_done) ) { #if OMPT_SUPPORT ompt_task_info_t *task_info; + ompt_parallel_id_t my_parallel_id; if (ompt_enabled) { task_info = __ompt_get_taskinfo(0); + my_parallel_id = (*pteam)->t.ompt_team_info.parallel_id; } #endif /* we were just woken up, so run our new task */ @@ -5550,7 +5552,8 @@ __kmp_launch_thread( kmp_info_t *this_thr ) #if OMPT_SUPPORT && OMPT_TRACE if (ompt_enabled) { if (ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)) { - int my_parallel_id = (*pteam)->t.ompt_team_info.parallel_id; + // don't access *pteam here: it may have already been freed + // by the master thread behind the barrier (possible race) ompt_callbacks.ompt_callback(ompt_event_implicit_task_end)( my_parallel_id, task_info->task_id); } |