• Kirill Smelkov's avatar
    libpyxruntime: Fix deadlock in pygil_ensure() · 73182038
    Kirill Smelkov authored
    pygil_ensure() was taking pyexitedMu and then GIL, which can deadlock
    via AB BA scenario if pygil_ensure() is also called in another thread
    with GIL already held.
    
    -> Fix it by always taking GIL with pyexitedMu released.
    
    Without the fix the test added always hangs with thread backend, e.g.
    like this:
    
        golang/pyx/runtime_test.py::test_pyx_pyfunc_vs_gil_deadlock
        STUCK
        terminate called after throwing an instance of 'golang::PanicError'
          what():  STUCK
        Fatal Python error: Aborted
    
    The bug was introduced in b073f6df (time: Move/Port timers to C++/Pyx nogil).
    73182038
setup.py 11.6 KB