Message296876
Ok, I think I've managed to dig to the core issue. It is actually the same issue as https://bugs.python.org/issue11768 (which was wrongly closed as fixed, apparently :-)).
Py_AddPendingCall() calls PyThread_acquire_lock() to try and take the pending calls lock. Unfortunately, PyThread_acquire_lock() is not reentrant in the case where semaphores are not used (e.g. on OS X). We can probably fix that first issue by calling pthread_mutex_trylock() instead of pthread_mutex_lock().
There is a second more fundamental issue, though, which is that PyThread_acquire_lock() calls into functions that are not async-signal-safe (see http://man7.org/linux/man-pages/man7/signal-safety.7.html for a list). So, depending on the particular OS and libc implementation, PyThread_acquire_lock() can fail in mysterious ways (including hang the process) when called from a signal handler.
So perhaps the ultimate fix would be to remove the OS-based locking in Py_AddPendingCall and use a busy spinwait... The performance implications may be bad, though. |
|
Date |
User |
Action |
Args |
2017-06-26 11:46:23 | pitrou | set | recipients:
+ pitrou, ronaldoussoren, vstinner, ned.deily, njs, neologix, mattbillenstein |
2017-06-26 11:46:23 | pitrou | set | messageid: <1498477583.61.0.166981063766.issue30703@psf.upfronthosting.co.za> |
2017-06-26 11:46:23 | pitrou | link | issue30703 messages |
2017-06-26 11:46:23 | pitrou | create | |
|