[OpenMP][libomp] Hold old __kmp_threads arrays until library shutdown
authorJonathan Peyton <jonathan.l.peyton@intel.com>
Thu, 5 May 2022 14:15:41 +0000 (09:15 -0500)
committerJonathan Peyton <jonathan.l.peyton@intel.com>
Wed, 22 Jun 2022 15:30:35 +0000 (10:30 -0500)
commitb7b498657685d7a305987b9140253523e77fd4e1
tree5a3863e03b8841ec3ec4f3223ac5b006931c85ea
parent106151100867041f705a0cdf25dfe1f732b28443
[OpenMP][libomp] Hold old __kmp_threads arrays until library shutdown

When many nested teams are formed, __kmp_threads may be reallocated
to accommodate new threads. This reallocation causes a data
race when another existing team's thread simultaneously references
__kmp_threads. This patch keeps the old thread arrays around until library
shutdown so these lingering references can complete without issue and
access to __kmp_threads remains a simple array reference.

Fixes: https://github.com/llvm/llvm-project/issues/54708
Differential Revision: https://reviews.llvm.org/D125013
openmp/runtime/src/kmp.h
openmp/runtime/src/kmp_global.cpp
openmp/runtime/src/kmp_runtime.cpp