dbTalk Databases Forums  

[BUGS] SIGSEGV in PQreset(..)

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] SIGSEGV in PQreset(..) in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Arturs Zoldners
 
Posts: n/a

Default [BUGS] SIGSEGV in PQreset(..) - 02-13-2006 , 03:34 PM






OS: FC4, 2.6.11-1.1369_FC4
PostgreSQL: postgresql-8.1.2-1PGDG (rpm install)
gcc: version 4.0.2 20051125 (Red Hat 4.0.2-8)

The following code raises SIGSEGV:

main.cpp (gcc -lstdc++ -lpq -g main.cpp)

extern "C"
{
#include <libpq-fe.h>
}
int main(int arch, char* argv[])
{
PGconn* conn = PQconnectdb("x");
ConnStatusType status = PQstatus(conn);
//status == CONNECTION_BAD
PQreset(conn);
return 0;
}

gdb:
Program received signal SIGSEGV, Segmentation fault.
0x0061371e in connectDBStart (conn=0x9f82008) at fe-connect.c:798

However, this code works ok:

main.cpp (gcc -lstdc++ -lpq -g main.cpp)

extern "C"
{
#include <libpq-fe.h>
}
int main(int arch, char* argv[])
{
PGconn* conn = PQconnectdb("user='x' password='x' dbname='x'");
ConnStatusType status = PQstatus(conn);
//status == CONNECTION_BAD
PQreset(conn);
status = PQstatus(conn);
//status == CONNECTION_BAD
return 0;
}

In both cases postmaster is not running.
The "successful" completion of second sample suggests me that SIGSEGV in the first sample is triggered by a bug.
Or is there any other return code indicating badly formated argument passed to PQconnectdb function?
I'm sorry if this is just a wrong usage of libpq API from my side.

Regards,
az



---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] SIGSEGV in PQreset(..) - 02-13-2006 , 04:09 PM






Arturs Zoldners <az (AT) rpiva (DOT) lv> writes:
Quote:
The following code raises SIGSEGV:

PGconn* conn = PQconnectdb("x");
ConnStatusType status = PQstatus(conn);
//status == CONNECTION_BAD
PQreset(conn);
PQreset assumes it's been passed a reasonably valid PGconn, which is not
the case if conninfo_parse couldn't make any sense of the connect
options string. We probably ought to add a state flag to indicate
whether the options have been set up successfully, and cause PQreset to
fail if not. (The alternative seems to be for PQreset to refuse to do
anything if the connection state is CONNECTION_BAD, but that looks like
it would destroy most of the usefulness of PQreset ...)

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.