From dff0ee2f4ecfa953bb575ea6bd5df0280ca84d4b Mon Sep 17 00:00:00 2001 From: Jonathan Peyton Date: Tue, 24 Oct 2017 16:10:09 +0000 Subject: Disable threadprivate data cleanup if runtime is terminating The problem is due to the runtime's threadprivate cleanup code which tries to access data that was already destroyed by one of the root threads. __kmp_init_gtid is used as a checker here since it is set to false before actual resource cleanup is done in __kmp_cleanup(). Patch by Hansang Bae llvm-svn: 316452 --- openmp/runtime/src/kmp_threadprivate.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'openmp/runtime/src') diff --git a/openmp/runtime/src/kmp_threadprivate.cpp b/openmp/runtime/src/kmp_threadprivate.cpp index bbcfadd7961..362c0757f98 100644 --- a/openmp/runtime/src/kmp_threadprivate.cpp +++ b/openmp/runtime/src/kmp_threadprivate.cpp @@ -226,6 +226,13 @@ void __kmp_common_destroy_gtid(int gtid) { struct private_common *tn; struct shared_common *d_tn; + if (!TCR_4(__kmp_init_gtid)) { + // This is possible when one of multiple roots initiates early library + // termination in a sequential region while other teams are active, and its + // child threads are about to end. + return; + } + KC_TRACE(10, ("__kmp_common_destroy_gtid: T#%d called\n", gtid)); if ((__kmp_foreign_tp) ? (!KMP_INITIAL_GTID(gtid)) : (!KMP_UBER_GTID(gtid))) { -- cgit v1.2.3