[C-API] Weird sys.exc_info reference segfault
Jonas H.
jonas at lophus.org
Sun Oct 3 10:33:48 EDT 2010
On 10/03/2010 03:47 PM, Antoine Pitrou wrote:
> 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.
Humm. Now the behaviour is as follows:
with assignment to local variable
----------------------------------
* start_response = PyObject_NEW(...) -> start_response->ob_refcnt=1
* wsgiapp(environ, start_response) -> ob_refcnt=2
* Py_DECREF(start_response) -> ob_refcnt=1
without assignment
------------------
* start_response = PyObject_NEW(...) -> start_respinse->ob_refcnt=1
* wsgiapp(environ, start_response) -> ob_refcnt=1
* Py_DECREF(start_response): CRASH
I think I'll compile Python with debug support to check out what's going
wrong in the second case.
Jonas
More information about the Python-list
mailing list