Thread: BUG #1131: PQfinish hangs
The following bug has been logged online: Bug reference: 1131 Logged by: Walter Lübker Email address: w.luebker@t-online.de PostgreSQL version: 7.4 Operating system: suse linux 8.2 Description: PQfinish hangs Details: I'm having some problems using libpq: Some details: OS: Suse Linux 8.2 Postgres version 7.4 The Server and client are at the same machine. I made a connection to the Backend Server using libpq. Establish some query's. Everything works fine. At end of my program I made a PQfinish. Sometime's the system hangs in PQfinish ! snip: if(db->pg_conn != NULL){ ConnStatusType = PQstatus(db->pg_conn); if(ConnStatusType == CONNECTION_OK){ fprintf(stderr,"vor PQfinish\n\r"); PQfinish(db->pg_conn); fprintf(stderr,"nach PQfinish\n\r"); }else{ (void)strcpy(dvs_info.subr, "PG_SQL_DENDE"); dvs_info.code = ConnStatusType; (void)strcpy(dvs_info.sql_cmd, "PQfinish"); (void)strcpy(dvs_info.text, "Fehler bei PQstatus"); dvs_log_error(); } db->pg_conn = NULL; } Any help or ideas greatly appreciated, Walter
"PostgreSQL Bugs List" <pgsql-bugs@postgresql.org> writes: > Sometime's the system hangs in PQfinish ! Hmm, that's a new one; don't think anyone has reported anything like that before. The closest thing that comes to mind is that most of the 7.3.* series had data-transfer problems when using SSL-encrypted connections, because of various bugs in the SSL-calling code in libpq. Is this connection using SSL? Is it possible that your program is linking to the 7.3 rather than 7.4 version of libpq? If that's not it then you'll need to provide more information. Could you get a stack backtrace to show just where it's hanging up? regards, tom lane
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