Re: segfaults

"James Henstridge" <[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On 06/03/2008, Robert Coup <[email protected]> wrote:
> Hey folks,
>
>  I've had some random segfaults in psycopg over the last week in a few
>  systems. Previously they've been fine, and other systems configured
>  the same run fine. Building a small testcase is tricky, the problem
>  comes and goes and there's a number of other C modules loaded in the
>  application. So, I'm looking for ideas. We're running psycopg2 from
>  r921 under Python2.5, on Ubuntu Feisty under amd64 & i386 (errors
>  occur on both) against Postgres8.2.
>
>  Traceback is below. #1/#2 is interesting, line 701 of pqpath suggests
>  PyTuple_New() should be called with size=7 statically.
>
>  Ringing any bells for anyone?

That bit of code looks like it is buggy w.r.t. handling of the global
interpreter lock -- calling Python APIs while not holding the GIL is
an error.

Could you try applying the attached patch and see if it fixes your
problem?  If you are still having problems, could you try upgrading to
the latest revision?

James.

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
pqpath-threads.patch (text/x-patch, 619 B)
Index: psycopg/pqpath.c
===================================================================
--- psycopg/pqpath.c	(revision 938)
+++ psycopg/pqpath.c	(working copy)
@@ -688,11 +688,13 @@
         int fsize = PQfsize(curs->pgres, i);
         int fmod =  PQfmod(curs->pgres, i);
 
-        PyObject *dtitem = PyTuple_New(7);
-        PyObject *type = PyInt_FromLong(ftype);
+        PyObject *dtitem;
+        PyObject *type;
         PyObject *cast = NULL;
 
         Py_BLOCK_THREADS;
+        dtitem = PyTuple_New(7);
+        type = PyInt_FromLong(ftype);
 
         PyTuple_SET_ITEM(curs->description, i, dtitem);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.