Thread: BUG #15226: (Changes in) LIBPQ prevents proper error captures andcrash client programs instead
BUG #15226: (Changes in) LIBPQ prevents proper error captures andcrash client programs instead
From
PG Bug reporting form
Date:
The following bug has been logged on the website: Bug reference: 15226 Logged by: Lance Zhang Email address: lance.zhang@gmail.com PostgreSQL version: 10.4 Operating system: Windows 10 Description: This mimimal test program will not run properly if the SQL supplied is illegal. It crashes inside libqp. No chance is offered to client program to detect and correct the error with facilities like PQerrorMessage(...). #include <stdio.h> #include <libpq-fe.h> #include <libpq/libpq-fs.h> int main() { PGresult * r; PGconn * conn; ExecStatusType status; /* Note: if it's a wrong password, the error can be detected and processed decently. Not when you supply an * non-exisiting dbname, etc. But this is not the point of this bug report */ conn=PQconnectdb("host=localhost dbname=postgres user=postgres password='/*YOUR PASSWORD*/'"); if( PQstatus(conn)!= CONNECTION_OK ){ fprintf(stderr, "Error connecting to database:%s!\n", PQerrorMessage(conn)); PQfinish(conn); exit(-1); } /* The next statement will crash the program inside libpq, because of the illegal SQL statement */ r=PQexec(conn,"SELECT SELECT FROM FROM"); /* the error detection mechanism in the next statement never gets a chance to be used */ status=PQresultStatus(r); if(status==PGRES_BAD_RESPONSE || status==PGRES_FATAL_ERROR) { fprintf(stderr,"Error executing SQL:%s!\n", PQerrorMessage(conn)); PQclear(r); PQfinish(conn); exit(-2); } PQclear(r); PQfinish(conn); return 0; }
Re: BUG #15226: (Changes in) LIBPQ prevents proper error captures andcrash client programs instead
From
Jeff Janes
Date:
On Sun, Jun 3, 2018 at 8:03 AM, PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug has been logged on the website:
Bug reference: 15226
Logged by: Lance Zhang
Email address: lance.zhang@gmail.com
PostgreSQL version: 10.4
Operating system: Windows 10
Description:
This mimimal test program will not run properly if the SQL supplied is
illegal. It crashes inside libqp. No chance is offered to client program to
detect and correct the error with facilities like PQerrorMessage(...).
Works for me. What is your build chain and compilation command line? How did you install PostgreSQL?
Cheers,
Jeff