EZ> You will have to provide a more detailed analysis, sorry. There is no guarantee the static variable `threads_holding_glib_lock` introduced in xgselect.c in commit 9c62ffb is synchronized across threads. As such, relying on it becoming zero in time for release_select_lock() is fraught. (If you add print statements, this particular heisenbug disappears, at least on Linux kernel 4.15.0-99-generic). Four attachments: 1. Desired patch to master (reverts 9c62ffb, adds main-thread-p check).