Thread: clients segfault on 9.2

clients segfault on 9.2

From
Grégoire Hubert
Date:
Hi,

I have cloned a fresh pg9.2 from github release 7c0fecd and compiled it with

./configure --prefix=$HOME/local --with-openssl && make && make install

The compilation went like a charm in a LXC container running a debian
6.0 with  following kernel

Linux java 3.0.0-21-generic #35-Ubuntu SMP Fri May 25 17:58:20 UTC
2012 i686 GNU/Linux

(system that hosts the LXC is an ubuntu).

I have successfuly run initdb and pg_ctl launched the database server
as usual. When I wanted to use any client to the database (psql,
createdb), they segfaulted whatever I used the TCP/IP or unix socket,
all with « trust » authentication in the pg_hba.conf.

Here is a ldd of the psql binary :

$ ldd ~/local/bin/psql       linux-gate.so.1 =>  (0x00376000)       libpq.so.5 => /home/greg/local/lib/libpq.so.5
(0x008e7000)      libreadline.so.6 => /lib/libreadline.so.6 (0x00ecd000)       libc.so.6 => /lib/libc.so.6 (0x00c7b000)
     libssl.so.0.9.8 => /usr/lib/i686/cmov/libssl.so.0.9.8 (0x00443000)       libpthread.so.0 => /lib/libpthread.so.0
(0x00110000)      libncurses.so.5 => /lib/libncurses.so.5 (0x00a32000)       /lib/ld-linux.so.2 (0x00843000)
libcrypto.so.0.9.8=> /usr/lib/i686/cmov/libcrypto.so.0.9.8 (0x00129000)       libdl.so.2 => /lib/libdl.so.2
(0x00281000)      libz.so.1 => /usr/lib/libz.so.1 (0x0077d000) 

Here is an excerpt of strace's output from the psql segfault (last lines)
$ strace -s 400 ~/local/bin/psql
...
stat64("/home/greg/.pgpass", 0xbfcdd3c0) = -1 ENOENT (No such file or directory)
socket(PF_FILE, SOCK_STREAM, 0)         = 3
fcntl64(3, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
connect(3, {sa_family=AF_FILE, path="/tmp/.s.PGSQL.5432"}, 110) = 0
getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
getsockname(3, {sa_family=AF_FILE, NULL}, [2]) = 0
poll([{fd=3, events=POLLOUT|POLLERR}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
send(3, "\0\0\0L\0\3\0\0user\0greg\0database\0greg\0application_name\0psql\0client_encoding\0UTF8\0\0",
76, MSG_NOSIGNAL) = 76
poll([{fd=3, events=POLLIN|POLLERR}], 1, -1) = 1 ([{fd=3, revents=POLLIN}])
recv(3, "R\0\0\0\10\0\0\0\0E\0\0\0RSFATAL\0C3D000\0Mdatabase \"greg\"
does not exist\0Fpostinit.c\0L718\0RInitPostgres\0\0", 16384, 0) = 92
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Segmentation fault

I know database greg does not exist. This segfaults also when I try to
connect to the template1 database:
...
stat64("/home/greg/.pgpass", 0xbfc56c80) = -1 ENOENT (No such file or directory)
socket(PF_FILE, SOCK_STREAM, 0)         = 3
fcntl64(3, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
connect(3, {sa_family=AF_FILE, path="/tmp/.s.PGSQL.5432"}, 110) = 0
getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
getsockname(3, {sa_family=AF_FILE, NULL}, [2]) = 0
poll([{fd=3, events=POLLOUT|POLLERR}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
send(3, "\0\0\0Q\0\3\0\0user\0greg\0database\0template1\0application_name\0psql\0client_encoding\0UTF8\0\0",
81, MSG_NOSIGNAL) = 81
poll([{fd=3, events=POLLIN|POLLERR}], 1, -1) = 1 ([{fd=3, revents=POLLIN}])
recv(3, "R\0\0\0\10\0\0\0\0S\0\0\0\32application_name\0psql\0S\0\0\0\31client_encoding\0UTF8\0S\0\0\0\27DateStyle\0ISO,

MDY\0S\0\0\0\31integer_datetimes\0on\0S\0\0\0\33IntervalStyle\0postgres\0S\0\0\0\24is_superuser\0on\0S\0\0\0\31server_encoding\0UTF8\0S\0\0\0\34server_version\0009.3devel\0S\0\0\0\37session_authorization\0greg\0S\0\0\0#standard_conforming_strings\0on\0S\0\0\0\21TimeZone\0UTC\0K\0\0\0\f\0\0I\4\177a\3119Z\0\0\0\5I",
16384, 0) = 321
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
Segmentation fault

Is there anything I did wrong ?

Regards,
--
Grégoire HUBERT


Re: clients segfault on 9.2

From
Grégoire Hubert
Date:
2012/8/2 Grégoire Hubert <gregoire.hubert@knplabs.com>:
> Hi,
>
> I have cloned a fresh pg9.2 from github release 7c0fecd and compiled it with
>
> ./configure --prefix=$HOME/local --with-openssl && make && make install
>
> The compilation went like a charm in a LXC container running a debian
> 6.0 with  following kernel
>
> Linux java 3.0.0-21-generic #35-Ubuntu SMP Fri May 25 17:58:20 UTC
> 2012 i686 GNU/Linux
>
> (system that hosts the LXC is an ubuntu).
>
> I have successfuly run initdb and pg_ctl launched the database server
> as usual. When I wanted to use any client to the database (psql,
> createdb), they segfaulted whatever I used the TCP/IP or unix socket,
> all with « trust » authentication in the pg_hba.conf.

Hi again,

I forgot to say I got postgres from the master branch.

I ran gdb, here is the stack trace :

~:$ gdb local/bin/psql
GNU gdb (GDB) 7.0.1-debian
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/greg/local/bin/psql...(no debugging symbols
found)...done.
(gdb) where
No stack.
(gdb) run
Starting program: /home/greg/local/bin/psql
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x001457dc in resetPQExpBuffer () from /home/greg/local/lib/libpq.so.5
(gdb) where
#0  0x001457dc in resetPQExpBuffer () from /home/greg/local/lib/libpq.so.5
#1  0x0013b41f in pqPrepareAsyncResult () from /home/greg/local/lib/libpq.so.5
#2  0x0013c5f0 in PQgetResult () from /home/greg/local/lib/libpq.so.5
#3  0x00136506 in PQconnectPoll () from /home/greg/local/lib/libpq.so.5
#4  0x00137800 in connectDBComplete () from /home/greg/local/lib/libpq.so.5
#5  0x001387c4 in PQconnectdbParams () from /home/greg/local/lib/libpq.so.5
#6  0x08058ef5 in main ()
(gdb)


Cheers
--
Grégoire HUBERT


Re: clients segfault on 9.2

From
Tom Lane
Date:
Grégoire Hubert <gregoire.hubert@knplabs.com> writes:
> I have cloned a fresh pg9.2 from github release 7c0fecd and compiled it with
> ./configure --prefix=$HOME/local --with-openssl && make && make install
> [ but libpq crashes at startup ]

Just to try to narrow things down a bit: does the behavior change if you
build without openssl?
        regards, tom lane


Re: clients segfault on 9.2

From
Grégoire Hubert
Date:
2012/8/2 Tom Lane <tgl@sss.pgh.pa.us>:
> Grégoire Hubert <gregoire.hubert@knplabs.com> writes:
>> I have cloned a fresh pg9.2 from github release 7c0fecd and compiled it with
>> ./configure --prefix=$HOME/local --with-openssl && make && make install
>> [ but libpq crashes at startup ]
>
> Just to try to narrow things down a bit: does the behavior change if you
> build without openssl?
>

It works : psql (9.3devel) \o/

I kept compiling with ssl support because lauching postgres directly
from the command line ended with a SSL error (FATAL:  SSL is not
supported by this build) whatever SSL is compiled or not. It works
when using pg_ctl to launch the server (whatever SSL support is
compiled or not).

Thank you.
--
Grégoire HUBERT


Re: clients segfault on 9.2

From
Tom Lane
Date:
Grégoire Hubert <gregoire.hubert@knplabs.com> writes:
> 2012/8/2 Tom Lane <tgl@sss.pgh.pa.us>:
>> Just to try to narrow things down a bit: does the behavior change if you
>> build without openssl?

> It works : psql (9.3devel) \o/

Hmm.  The first reaction is to guess that there's something flaky about
your openssl installation.  Perhaps the headers don't match the library
version, or something like that?

> I kept compiling with ssl support because lauching postgres directly
> from the command line ended with a SSL error (FATAL:  SSL is not
> supported by this build) whatever SSL is compiled or not.

That seems a bit odd too, unless you had "ssl = on" in postgresql.conf.
hostssl lines in pg_hba.conf might cause that too; I don't recall if
there's a separate error message for such cases.
        regards, tom lane