[issue38680] PyGILState_Release does not release gil correctly, resulting in deadlock

2019-11-21 Thread Damien LEFEVRE
Damien LEFEVRE added the comment: Here is a code example reproducing the issue. -- Added file: https://bugs.python.org/file48728/interpreterlock.zip ___ Python tracker ___

[issue38680] PyGILState_Release does not release gil correctly, resulting in deadlock

2019-11-19 Thread Damien LEFEVRE
Damien LEFEVRE added the comment: Back to testing this. I have the same issue on Linux, i.e: the deadlock on PyGILState_Ensure. I cannot test 3.8 because many of the modules are not yet available for this version. I'll try making a small test application to reproduce the issue. --

[issue38680] PyGILState_Release does not release gil correctly, resulting in deadlock

2019-11-05 Thread Ronald Oussoren
Ronald Oussoren added the comment: I'm afraid it will be close to impossible to determine what's going on without a reproducer. There's not enough context in the issue to understand the report, in particular what the main thread is doing and how that's releasing the GIL. BTW. The code in

[issue38680] PyGILState_Release does not release gil correctly, resulting in deadlock

2019-11-05 Thread Damien LEFEVRE
Damien LEFEVRE added the comment: @ronaldoussoren The issue here is that the behavior between Python 3.6 and 3.7 has changed. Our code runs perfectly fine with 3.6. We release the lock each time our functions get out of scope and so we know for sure there is no lock left behind. Starting

[issue38680] PyGILState_Release does not release gil correctly, resulting in deadlock

2019-11-05 Thread Ronald Oussoren
Ronald Oussoren added the comment: I don't think this is a bug: - PyGILState_Ensure() acquires the GIL when it is not already acquired (and can be called without checking). It cannot acquire the GIL when some other thread has already taken the GIL, but wait until the GIL is released.

[issue38680] PyGILState_Release does not release gil correctly, resulting in deadlock

2019-11-05 Thread Damien LEFEVRE
Damien LEFEVRE added the comment: I see the same problem. We call python functions from C++ and use this locking class within each call: ''' #pragma once #ifdef _DEBUG #undef _DEBUG #include #define _DEBUG #else #include #endif // _DEBUG #include "gcc_helper.h"

[issue38680] PyGILState_Release does not release gil correctly, resulting in deadlock

2019-11-04 Thread Ronald Oussoren
Ronald Oussoren added the comment: What's the value of PyGILState_Check() before the call to PyGILState_Ensure()? PyGILState_Ensure() and PyGILState_Release() should bracket code where you're not sure about the current GIL state, but need the GIL. The Release function only undoes the

[issue38680] PyGILState_Release does not release gil correctly, resulting in deadlock

2019-11-03 Thread 123 wlpha
123 wlpha added the comment: Usually in the python extension, only the python function needs to be written between Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW THREADS, but the c callback function needs PyGILState_Ensure and PyGILState_Release, but PyGILState_Releas cannot release gil correctly.

[issue38680] PyGILState_Release does not release gil correctly, resulting in deadlock

2019-11-03 Thread 123 wlpha
New submission from 123 wlpha : PyGILState_Release does not really release gil, causing the next PyGILState_Ensure deadlock, now you need to call if (PyGILState_Check () > 0) {PyEval_SaveThread ();} ``` auto gil = PyGILState_Ensure(); // call c api PyGILState_Release (gil); if