Hello everyone, I ran into a problem writing a program using libpq, and after postin on a forum and asking it on the irc channel I was redirected here.
I'll try to keep it simple so you don't have to read to much to start: The program is asynchronous using libev, using sockets and notifications to wake up. Notifications is done with connection conn_async, queries are done using conn_block with PQexec. PGresult *res; is defined global. When a notification arrives, the callback goes something like: PGresult *res2; res2 = PQexec(conn_async, "select stuff"); // yes, this is the only time I use conn_async for a query for( i<PQntuples(res2)) { if(row[i] values of res2) call function x } PQclear(res2) function x { PGresult *resu; resu = PQexec(conn_block,"select other stuff"); for(i<PQntuples(resu)) send stuff to the clients over the sockets. PQclear(resu); } The program crashes on PQclear(resu) with the following: *** glibc detected *** ./incident_relay: corrupted double-linked list: 0x09c459c8 *** ======= Backtrace: ========= /lib/libc.so.6[0x63b9aa] /lib/libc.so.6(cfree+0x90)[0x63f0f0] /usr/lib/libpq.so.5(PQclear+0x49)[0xae1759] ./incident_relay[0x80507de] ./incident_relay[0x804f5d8] /usr/local/lib/libev.so.3(ev_loop+0x939)[0x117f89] ./incident_relay[0x8049a4a] /lib/libc.so.6(__libc_start_main+0xe0)[0x5e8390] ./incident_relay[0x8049311] I'm no longer using the global res in the function x but resu as I thought it may have something to do with forgetting a PQclear somewhere or ... (although I quadripple checked that by now) Some system info: Select version() => "PostgreSQL 8.3.4 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8)" (Fedora 9) My system (running the program): Linux 2.6.26.8-57.fc8 #1 SMP Thu Dec 18 19:19:45 EST 2008 i686 athlon i386 GNU/Linux Thanks in advance, Maarten P.S.: I'm not subscribed to the list. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers