Re: PQdb() fails with coredump when PQconnectDB() passed invalid parameter.

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Trevor Inns <trevor(dot)inns(at)geering(dot)biz>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: PQdb() fails with coredump when PQconnectDB() passed invalid parameter.
Date: 2004-10-01 14:51:52
Message-ID: 20041001145151.GA19497@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Sep 29, 2004 at 05:59:37PM +0100, Trevor Inns wrote:
> version 7.4.5
>
> using postgresql-7.4.5/src/test/examples/testlibpq as follows
>
> "testlibpq hostname=shouldHaveUsedHostNotHostname"
>
> fails with coredump
>
> SunOS pluto 5.9 Generic_117171-07 sun4u sparc SUNW,Ultra-5_10

Confirmed on Solaris 9 with PostgreSQL 8.0.0beta3 (CVS). Here's
a stack trace:

#0 0xff1344e4 in strlen () from /usr/lib/libc.so.1
#1 0xff186bec in _doprnt () from /usr/lib/libc.so.1
#2 0xff18861c in fprintf () from /usr/lib/libc.so.1
#3 0x00010a08 in main (argc=135304, argv=0x10cd8) at testlibpq.c:44

Here's line 44:

fprintf(stderr, "Connection to database '%s' failed.\n", PQdb(conn));

PQdb() is returning NULL, which causes fprintf() to dump core.
On FreeBSD 4.10-STABLE, fprintf() handles NULL:

Connection to database '(null)' failed.
invalid connection option "hostname"

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2004-10-01 15:06:39 Re: Disk space is consumed by UPDATE query
Previous Message Ivan 2004-10-01 14:13:35 pg_dumpall fails