libpq incompatibility

Started by Admin Gastonover 22 years ago2 messagesbugs
Jump to latest
#1Admin Gaston
admin@intergamesclub.com

Hi, sorry my english. Recently i was using postgresql 7.2, and then i update to 7.3.3. We was running a C program that was working fine with 7.2, but in 7.3.3 it seg fault.

int procesarConsultasSQL(int nCliente){
.......... more code
FD_SET(cli->socketDB, &readfds);
timeout.tv_sec = timeout.tv_usec = 0;
select(cli->socketDB + 1, &readfds, NULL, NULL, &timeout);
if (FD_ISSET(cli->socketDB, &readfds)){
if (PQconsumeInput(cli->conn)){
if (!PQisBusy(cli->conn)){
while ((cli->res = PQgetResult(cli->conn)) != NULL){
//procesamos los datos devueltos por la base de datos, ya sean
//select's o update's y lo agregamos en la cola de envio del cliente
switch(PQresultStatus(cli->res)){
....... more code
}
....... more code
PQclear(cli->res);
}
........ more code
}
}
}
....... more code
}

When the program is running for a while, it finish with segmentation fault (core dumped).

#0 0x420742e2 in _int_malloc () from /lib/tls/libc.so.6
#1 0x4207360b in malloc () from /lib/tls/libc.so.6
#2 0x400278b3 in PQmakeEmptyPGresult () from /usr/lib/libpq.so.3
#3 0x40028387 in PQconsumeInput () from /usr/lib/libpq.so.3
#4 0x400282f1 in PQconsumeInput () from /usr/lib/libpq.so.3
#5 0x4002886a in PQisBusy () from /usr/lib/libpq.so.3
#6 0x0804c3dc in procesarConsultasSQL(int) ()
#7 0x0804cfe0 in main ()

Is this a know bug?, or the way i am programming this isn't correct? Any help is aprecciated, and thanks to Tom Lane for my other problem, it was solved.

Regards,
Tavella Gaston.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Admin Gaston (#1)
Re: libpq incompatibility

"Admin Gaston" <admin@intergamesclub.com> writes:

When the program is running for a while, it finish with segmentation fault =
(core dumped).

#0 0x420742e2 in _int_malloc () from /lib/tls/libc.so.6
#1 0x4207360b in malloc () from /lib/tls/libc.so.6
#2 0x400278b3 in PQmakeEmptyPGresult () from /usr/lib/libpq.so.3

This looks like something has tromped on malloc's private data
structures --- that is, it wrote outside the boundaries of a malloc'd
data object. Check your code for buffer overruns. Also check for
something that didn't get recompiled after a change in a struct
declaration it depended on.

I doubt that it's libpq's problem per se.

regards, tom lane