classification
Title: access violation in PyErrFetch if tcur==null in PyGILState_Release
Type: crash Stage:
Components: Interpreter Core Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, cberger, vstinner
Priority: normal Keywords:

Created on 2016-01-13 19:47 by cberger, last changed 2016-03-15 16:31 by vstinner. This issue is now closed.

Messages (2)
msg258164 - (view) Author: Christian Berger (cberger) Date: 2016-01-13 19:47
I've been messing with PyGILState_... handling for my embedded python interpreter and came across this issue:

code in PyGILState_Release:

    PyThreadState *tcur = (PyThreadState *)PyThread_get_key_value(
                                                            autoTLSkey);
    if (tcur == NULL)
        Py_FatalError("auto-releasing thread-state, "
                      "but no thread-state for this thread");

The Py_FatalError() call will then invoke PyErr_Fetch() which won't check if PyThreadState_GET() returns a valid ptr (!= NULL):

PyErr_Fetch(PyObject **p_type, PyObject **p_value, PyObject **p_traceback)
{
    PyThreadState *tstate = PyThreadState_GET();
    *p_type = tstate->curexc_type;
msg261819 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-03-15 16:31
Good news: it looks like I fixed the Py_FatalError() bug in the issue #26558. Py_FatalError() can again be called with the GIL released.

The bug was introduced in Python 3.0.

Since your issue is a bug in your code and that Py_FatalError() was fixed, I close the issue. Thanks for your bug report.
History
Date User Action Args
2016-03-15 16:31:27vstinnersetstatus: open -> closed
versions: + Python 3.6
nosy: + vstinner

messages: + msg261819

resolution: fixed
2016-01-14 22:28:36SilentGhostsetnosy: + benjamin.peterson
2016-01-13 19:47:51cbergercreate