Re: BUG #1131: PQfinish hangs - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #1131: PQfinish hangs
Date
Msg-id 23483.1081872664@sss.pgh.pa.us
Whole thread Raw
In response to BUG #1131: PQfinish hangs  ("PostgreSQL Bugs List" <pgsql-bugs@postgresql.org>)
List pgsql-bugs
Walter Lübker <w.luebker@t-online.de> writes:
> here the stack trace:
> (gdb) bt
> #0  0x401e0f1a in malloc_consolidate () from /lib/libc.so.6
> #1  0x401e0e4f in _int_free () from /lib/libc.so.6
> #2  0x401dfa5f in free () from /lib/libc.so.6
> #3  0x40132fda in freePGconn () from /usr/lib/libpq.so.3
> #4  0x4009cb9f in pg_sql_dende (db=0x83a3f40) at pg_sql.c:830
> #5  0x4005a3d8 in cende (db=0x83a3f40) at dvs.c:3497
> #6  0x400761ec in dende (fbank=0xbfffe2f0, fin_err=0xbfffe48c, flu=0xbfffe454,
>     fnode=0xbfffe456) at fdvs.c:1533
> #7  0x0805a595 in main ()

Okay, so the hang is really inside free().  This is a pretty strong
indication that something has clobbered the memory allocation data
structures used by malloc/free.  Usually this happens because some
bit of code writes past the end of a chunk of memory it's requested
from malloc --- ie, overruns the buffer size it requested.  The point
at which you notice a problem is likely to be far removed from the
place where the error actually is.

It's possible that the overrun bug is in libpq, but it seems much
more likely that it's your own bug.  What I'd suggest is that you
rebuild your program with a debugging malloc package (ElectricFence
or dmalloc or one of the other dozen or so that are out there) and
see if it can't pinpoint the problem for you.

If you do find that the error is in libpq, then by all means let us
know ;-).  But the odds are it isn't.
        regards, tom lane


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #1130: server terminated by signal 11 (easy to duplicate)
Next
From: "PostgreSQL Bugs List"
Date:
Subject: BUG #1132: I can't connection to Postgresql