The problem was a hang when reducing a hot team's size and then increasing it again when KMP_HOT_TEAMS_MODE=1.
Threads that were removed but kept in the team for later re-use, and then added back later, were not properly set to wait on their own b_go flag. This was properly handled for the case when threads are returned to the pool, but not when kept in the team. However, this did not completely fix the hang.
The second problem was that a thread that was made active in the team again still thought it knew about its related leaf threads in the hierarchy, and tried to release them by setting it's own flag, as opposed to the leaves' flags. The leaves, however, were also recently made active again, and were thus waiting on their own b_go flags. The fix was easy: simply reset the known leaves to zero, via the "leaf_kids" field whenever threads in a team go inactive. The same problem would have existed for threads picked up from the pool, so this fix was made there as well.