"Heinz Ekker" <hekker@netway.at> writes:
> In my setup, which is RedHat 7.0, libc-2.2, glibc 2.96 (yes, the bad one)
> and perl 5.6.0 with DBI-1.14 and DBD-Pg-0.95 libpq.so.2.1 segfaults due to
> a null pointer dereference in printfPQExpBuffer.
> (gdb) bt
> #0 _IO_vsnprintf (string=0x0, maxlen=255,
> format=0x401f5ce0 "PQsendQuery() -- There is no connection to the
> backend.\n
> ", args=0xbffff620) at vsnprintf.c:127
> #1 0x401f4c2f in printfPQExpBuffer () from /opt/postgres/lib/libpq.so.2.1
> #2 0x401f0307 in PQsendQuery () from /opt/postgres/lib/libpq.so.2.1
> #3 0x401f0dc9 in PQexec () from /opt/postgres/lib/libpq.so.2.1
> #4 0x401e455c in dbd_db_commit ()
> from /usr/lib/perl5/site_perl/5.6.0/i386-linux/auto/DBD/Pg/Pg.so
> #5 0x401e10c6 in XS_DBD__Pg__db_commit ()
> from /usr/lib/perl5/site_perl/5.6.0/i386-linux/auto/DBD/Pg/Pg.so
> #6 0x401d57f7 in XS_DBI_dispatch ()
> from /usr/lib/perl5/site_perl/5.6.0/i386-linux/auto/DBI/DBI.so
> #7 0x809ddae in Perl_pp_entersub ()
> #8 0x809865a in Perl_runops_standard ()
> #9 0x805bfbe in perl_run ()
> #10 0x805bd22 in perl_run ()
> #11 0x8059a11 in main ()
I am going to guess that the root problem is in the Perl code: I suspect
that PQexec is being handed a bogus PGconn pointer --- possibly a
pointer to a connection object that had already been closed. Can't
prove it on this amount of data, however.
It does look like libpq will behave ungracefully in that case :-(.
Will fix that part.
regards, tom lane