The code fragments of recruiting a thread from pool (kmp_runtime.cpp:4297):
new_thr->th.th_in_pool = FALSE; __kmp_lock_suspend_mx(new_thr); if (new_thr->th.th_active_in_pool == TRUE) { ... else KMP_DEBUG_ASSERT(new_thr->th.th_active == FALSE);
and its awakening, executed under the mutex (z_Linux_util.cpp:1534):
th->th.th_active = TRUE; if (th->th.th_in_pool) { th->th.th_active_in_pool = TRUE; }
can be executed in parallel. Since the "th_in_pool=0" assignment is out of critical section, it is valid to have "th_active==1" and "th_active_in_pool==0" for the worker thread been recruited from common pool (e.g. in case of spurious wakeup). So the assertion triggered looks wrong. The patch deletes it.
I actually failed to reproduce the assertion on my server with RHEL7 (probably because it is hard to force spurious wakeup of a thread, and without it I failed to find code path of simultaneous execution of code fragments I referenced), but the patch looks logically correct.