[C-API] Weird sys.exc_info reference segfault
solipsis at pitrou.net
Sun Oct 3 15:47:36 CEST 2010
On Sun, 03 Oct 2010 14:44:32 +0200
"Jonas H." <jonas at lophus.org> wrote:
> On 10/03/2010 01:16 AM, Antoine Pitrou wrote:
> > You should check that you aren't doing anything wrong
> > with "env" and "start_response" (like deallocate them forcefully).
> I commented out the `Py_DECREF(start_response)` after the `app` call and
> the crash was gone. `start_response` is created via `PyObject_NEW` on
> run time for every `app` call and `PyObject_FREE`d after that call.
You shouldn't call PyObject_FREE yourself, but instead rely on
Py_DECREF to deallocate it if the reference count drops to zero.
So, instead of commenting out Py_DECREF and keeping PyObject_FREE, I'd
recommend doing the reverse. That way, if a reference is still living
in the frame, the object doesn't get deallocated too early.
More information about the Python-list