SIGSEGV in psycopg2 2.0.14 (and 2.2.0rc1)

Grzegorz Aksamit <grzegorz.aksamit-Mck9nA1XyXe1Z/[email protected]> Tue, 4 May 2010 14:30:39 +0200
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
Hi,

I'm having problems with psycopg2 crashing at random places with null
pointer reference. It crashes after few minutes of intensive use
(around two queries per second). The crash does not depend on query
itself, as it crashes on all of them. It looks more like some threads
related race condition.

Here's the backtrace from gdb:

Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/i386/i486/strlen.S:69
69      ../sysdeps/i386/i486/strlen.S: No such file or directory.
        in ../sysdeps/i386/i486/strlen.S
(gdb) bt
#0  strlen () at ../sysdeps/i386/i486/strlen.S:69
#1  0x0809f3ca in PyString_FromString ()
#2  0xb79e63c9 in _pq_fetch_tuples (curs=0x837de9c) at psycopg/pqpath.c:826
#3  pq_fetch (curs=0x837de9c) at psycopg/pqpath.c:1215
#4  0xb79e79aa in pq_execute (curs=0x837de9c,
    query=0x84503e4 "select
u.user_id,u.group_id,s.rank,s.last_sec_id,extract(epoch from
max_timestamp(s.last_position_time,max_timestamp(s.last_login_time,s.last_logout_time))),extract(epoch
from s.ban_stop_time),s.banne"..., async=0)
    at psycopg/pqpath.c:706
#5  0xb79ef2e4 in _psyco_curs_execute (self=<value optimized out>,
operation=<value optimized out>, vars=0x83fb28c, async=0) at
psycopg/cursor_type.c:433
#6  0xb79efbff in psyco_curs_execute (self=0x837de9c, args=0x841292c,
kwargs=0x0) at psycopg/cursor_type.c:488
#7  0x080e0703 in PyEval_EvalFrameEx ()
#8  0x080e2492 in PyEval_EvalCodeEx ()
#9  0x080e07e7 in PyEval_EvalFrameEx ()
#10 0x080e19b4 in PyEval_EvalFrameEx ()
#11 0x080e19b4 in PyEval_EvalFrameEx ()
#12 0x080e19b4 in PyEval_EvalFrameEx ()
#13 0x080e19b4 in PyEval_EvalFrameEx ()
#14 0x080e2492 in PyEval_EvalCodeEx ()
#15 0x080e2587 in PyEval_EvalCode ()
#16 0x080ffb3d in PyRun_FileExFlags ()
#17 0x080ffda2 in PyRun_SimpleFileExFlags ()
#18 0x0805db5b in Py_Main ()
#19 0x0805ce2b in main ()
(gdb)


I have the same issue with psycopg2 2.0.14 and 2.2.0rc1 installed by
easy_install and with psycopg2 2.0.14 compiled from src by myself. The
backtrace above is from a crash in src-compiled psycopg2.

I have few coredumps if you need them.

AFAIK the problems could be caused by libpq compiled without
--with-thread-safety - I'm using debian sid libpq5 8.4.1-1 package.
I'm not sure, but it should be compiled with thread safety option
enabled.

Can somebody help me with this issue? It makes my code completely
useless under heavy load.

Best regards
Grzegorz Aksamit