[pypy-issue] Issue #2764: cpyext PyEval_SaveThread/PyGILState_Ensure/PyErr_SetString failure (pypy/pypy)

pv issues-reply at bitbucket.org
Sun Feb 25 22:10:38 EST 2018


New issue 2764: cpyext PyEval_SaveThread/PyGILState_Ensure/PyErr_SetString failure
https://bitbucket.org/pypy/pypy/issues/2764/cpyext-pyeval_savethread-pygilstate_ensure

pv:

The following construction doesn't seem to work as expected with cpyext:
```
    save = PyEval_SaveThread();
    ...
    gilsave = PyGILState_Ensure();
    PyErr_SetString(PyExc_RuntimeError, "XXX");
    PyGILState_Release(gilsave);
    ...
    PyEval_RestoreThread(save);
    assert(PyErr_Occurred());
```
It appears that there are race conditions in this, so that another thread may end up with a spurious error status, or the assertion can fail.

A test case: https://github.com/pv/cpyextcrash1/tree/020f114b5e6e1af69ab776a1265332d8d8c5ff0b
It passes on CPython, but not on Pypy3-5.10.1 or pypy2-5.10.0




More information about the pypy-issue mailing list