Re: [C-API] Weird sys.exc_info reference segfault

2010-10-06 Thread Antoine Pitrou
On Tue, 05 Oct 2010 16:17:57 +0200 Jonas H. jo...@lophus.org wrote: Right now I have this minimal struct: static PyTypeObject StartResponse_Type = { PyObject_HEAD_INIT(PyType_Type) 0, /* ob_size */ start_response, /* tp_name */

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-06 Thread Jonas H.
On 10/06/2010 02:01 PM, Antoine Pitrou wrote: It shouldn't. Are you sure you're calling PyType_Ready in the module initialization routine? Yeah. The problem was that the type struct was declared 'static' in another module so the changes `PyType_Ready` made to the struct weren't applied

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-05 Thread Jonas H.
On 10/04/2010 11:41 PM, Antoine Pitrou wrote: Well, it should work, but you have to call PyType_Ready() to fill in the NULL fields with default values (for those where it's necessary). Does it solve it for you? Yes, thank you! Although I do not understand which fields I have to provide. I

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-04 Thread Jonas H.
On 10/03/2010 11:52 PM, Antoine Pitrou wrote: You probably have a problem in your tp_dealloc implementation. `tp_dealloc` is NULL... -- http://mail.python.org/mailman/listinfo/python-list

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-04 Thread Jonas H.
On 10/04/2010 10:46 AM, Jonas H. wrote: On 10/03/2010 11:52 PM, Antoine Pitrou wrote: You probably have a problem in your tp_dealloc implementation. `tp_dealloc` is NULL... Alright, `tp_dealloc` must not be NULL because it's called by `_Py_Dealloc`. The C-API tutorial is quite confusing

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-04 Thread Antoine Pitrou
On Mon, 04 Oct 2010 23:30:58 +0200 Jonas H. jo...@lophus.org wrote: [...] here's a minimal, but __complete__, module that defines a new type: [...] static PyTypeObject noddy_NoddyType = { [...] 0, /*tp_dealloc*/ [...] }; So I thought

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-03 Thread Jonas H.
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

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-03 Thread Antoine Pitrou
On Sun, 03 Oct 2010 14:44:32 +0200 Jonas H. jo...@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

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-03 Thread Jonas H.
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

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-03 Thread Antoine Pitrou
On Sun, 03 Oct 2010 16:33:48 +0200 Jonas H. jo...@lophus.org wrote: 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) -

[C-API] Weird sys.exc_info reference segfault

2010-10-02 Thread Jonas H.
Hello list, I have a really weird reference problem with `sys.exc_info`, and, if I'm right, function frames. The software in question is bjoern, a WSGI web server written in C, which you can find at http://github.com/jonashaag/bjoern. This WSGI application: def app(env, start_response):

Re: [C-API] Weird sys.exc_info reference segfault

2010-10-02 Thread Antoine Pitrou
On Sat, 02 Oct 2010 23:35:01 +0200 Jonas H. jo...@lophus.org wrote: This WSGI application: def app(env, start_response): start_response('200 alright', []) try: a except: import sys sys.exc_info() return ['hello']