File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -3982,12 +3982,19 @@ static int __kmp_reset_root(int gtid, kmp_root_t *root) {
3982
3982
3983
3983
TCW_4 (__kmp_nth,
3984
3984
__kmp_nth - 1 ); // __kmp_reap_thread will decrement __kmp_all_nth.
3985
- root->r .r_uber_thread ->th .th_cg_roots ->cg_nthreads --;
3985
+ i = root->r .r_uber_thread ->th .th_cg_roots ->cg_nthreads --;
3986
3986
KA_TRACE (100 , (" __kmp_reset_root: Thread %p decrement cg_nthreads on node %p"
3987
3987
" to %d\n " ,
3988
3988
root->r .r_uber_thread , root->r .r_uber_thread ->th .th_cg_roots ,
3989
3989
root->r .r_uber_thread ->th .th_cg_roots ->cg_nthreads ));
3990
-
3990
+ if (i == 1 ) {
3991
+ // need to free contention group structure
3992
+ KMP_DEBUG_ASSERT (root->r .r_uber_thread ==
3993
+ root->r .r_uber_thread ->th .th_cg_roots ->cg_root );
3994
+ KMP_DEBUG_ASSERT (root->r .r_uber_thread ->th .th_cg_roots ->up == NULL );
3995
+ __kmp_free (root->r .r_uber_thread ->th .th_cg_roots );
3996
+ root->r .r_uber_thread ->th .th_cg_roots = NULL ;
3997
+ }
3991
3998
__kmp_reap_thread (root->r .r_uber_thread , 1 );
3992
3999
3993
4000
// We canot put root thread to __kmp_thread_pool, so we have to reap it istead
You can’t perform that action at this time.
0 commit comments