On Mon, Sep 27, 2010 at 1:55 PM, Lisandro Dalcin <[email protected]> wrote: > consider this code: > > cdef void foo() except * with gil: > raise ValueError > > cdef int bar() except ? -1 with gil: > raise ValueError > > with nogil: > foo() > > with nogil: > bar() > > > Currently, Cython generates segfaulting code because in both cases it > is using PyErr_Occurred() without re-acquiring the GIL. I think the > easiest solution would be to use a utility code wrapping around > PyErr_Occurred() and implemented with the PyGILState_XXX API's, more > or less like below: > > int __Pyx_PyErr_Occurred_WithGIL() > { > int err; > _save = PyGILState_Ensure(); > err = !!PyErr_Occurred(); /* note: PyErr_Occurred() returns PyObject* */ > PyGILState_Release(_save); > return err; > } > > Of course, this function is going to be used ONLY when calling C > functions within nogil blocks. > > Would such fix be fine? I would prefer to use the Py_[UN]BLOCK_THREAD > macros, but in such case the fix is not trivial for me and I do not > want to make a mess... >
Yes, I would be fine with that for a fix. - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
