[OpenMP] Fix race condition in the completion/freeing of detached tasks
authorJoachim Protze <protze@itc.rwth-aachen.de>
Sun, 17 May 2020 10:25:02 +0000 (12:25 +0200)
committerJoachim Protze <protze@itc.rwth-aachen.de>
Sun, 17 May 2020 10:28:38 +0000 (12:28 +0200)
commitd23131a3c063830e3d8d4f7d43cbcf95d92db3d3
treebf1887ca4cdccafba3c43d774e95a74ec03bdbaa
parentf93a6aaebcf47528e51a6d943ca7699412f30234
[OpenMP] Fix race condition in the completion/freeing of detached tasks

Spurious assertion failures are symptoms of a race condition for the handling
of detached tasks:
Assertion failure at kmp_tasking.cpp(3744): taskdata->td_flags.complete == 1.
Assertion failure at kmp_tasking.cpp(710): taskdata->td_flags.executing == 0.

in the case of detach=true, all accesses to taskdata in __kmp_task_finish need
to happen before (~line 873):

taskdata->td_flags.proxy = TASK_PROXY;

This assignment signals to __kmp_fulfill_event, that the task will need to be
freed there. So, conceptionally the ownership of taskdata is moved.

Reviewed By: AndreyChurbanov

Differential Revision: https://reviews.llvm.org/D79702
openmp/runtime/src/kmp_tasking.cpp