summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/src/kmp_runtime.cpp
diff options
context:
space:
mode:
authorAndrey Churbanov <Andrey.Churbanov@intel.com>2019-04-17 10:44:28 +0000
committerAndrey Churbanov <Andrey.Churbanov@intel.com>2019-04-17 10:44:28 +0000
commitcf5bdb83b02a87823a25a4cf6de5fb88b43b8135 (patch)
tree850d3c0c14497ae21d288cda62426966f167612c /openmp/runtime/src/kmp_runtime.cpp
parent62e2472321b7c8c5954a69ecef953b1abf54e538 (diff)
downloadbcm5719-llvm-cf5bdb83b02a87823a25a4cf6de5fb88b43b8135.tar.gz
bcm5719-llvm-cf5bdb83b02a87823a25a4cf6de5fb88b43b8135.zip
Fixed memory leak reported in Bugzilla:
https://bugs.llvm.org/show_bug.cgi?id=41494 Freed th_cg_roots structure at exit from uber thread. Differential Revision: https://reviews.llvm.org/D60729 llvm-svn: 358572
Diffstat (limited to 'openmp/runtime/src/kmp_runtime.cpp')
-rw-r--r--openmp/runtime/src/kmp_runtime.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/openmp/runtime/src/kmp_runtime.cpp b/openmp/runtime/src/kmp_runtime.cpp
index 66726312d10..cd5bdba59c8 100644
--- a/openmp/runtime/src/kmp_runtime.cpp
+++ b/openmp/runtime/src/kmp_runtime.cpp
@@ -3982,12 +3982,19 @@ static int __kmp_reset_root(int gtid, kmp_root_t *root) {
TCW_4(__kmp_nth,
__kmp_nth - 1); // __kmp_reap_thread will decrement __kmp_all_nth.
- root->r.r_uber_thread->th.th_cg_roots->cg_nthreads--;
+ i = root->r.r_uber_thread->th.th_cg_roots->cg_nthreads--;
KA_TRACE(100, ("__kmp_reset_root: Thread %p decrement cg_nthreads on node %p"
" to %d\n",
root->r.r_uber_thread, root->r.r_uber_thread->th.th_cg_roots,
root->r.r_uber_thread->th.th_cg_roots->cg_nthreads));
-
+ if (i == 1) {
+ // need to free contention group structure
+ KMP_DEBUG_ASSERT(root->r.r_uber_thread ==
+ root->r.r_uber_thread->th.th_cg_roots->cg_root);
+ KMP_DEBUG_ASSERT(root->r.r_uber_thread->th.th_cg_roots->up == NULL);
+ __kmp_free(root->r.r_uber_thread->th.th_cg_roots);
+ root->r.r_uber_thread->th.th_cg_roots = NULL;
+ }
__kmp_reap_thread(root->r.r_uber_thread, 1);
// We canot put root thread to __kmp_thread_pool, so we have to reap it istead
OpenPOWER on IntegriCloud