[Bug 257323] databases/postgresql13-server: on 14-CURRENT/KTLS: Segmentation fault

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 22 Jul 2021 06:19:11 UTC

            Bug ID: 257323
           Summary: databases/postgresql13-server: on 14-CURRENT/KTLS:
                    Segmentation fault
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: Individual Port(s)
          Assignee: pgsql@FreeBSD.org
          Reporter: ohartmann@walstatt.org
             Flags: maintainer-feedback?(pgsql@FreeBSD.org)
          Assignee: pgsql@FreeBSD.org

The host is running 14-CURRENT (FreeBSD 14.0-CURRENT #109
main-n248146-5ab82b00cca: Thu Jul 22 04:53:13 CEST 2021 amd64), KTLS is
enabled. The host gets upgraded on a daily basis. 
The ports tree is also updated on a daily basis,
databases/postgresql13-{server|client} has been recompiled recently via
"portmaster -df" to ensure non-out-of-sync code with the base system.

The problem: No other connections to the server but via socket are possible.
Any connection via local socket is possible in any fashion (trust, md5 or
scram-sha-256 hashed passwords).
No TCP connection of any kind is possible: nor, ::1 or any remote
IPv4 or IPv6 connection to this host.
In postgresql's log the only entry, whatever loglevel is used, is:
2021-07-22 08:01:57.522 CEST [68352] LOG:  connection received: host=localhost
In this case it is a connection attempt of a local service via "localhost", but
one can replace this log entry's host= with any FQDN hostname or IPv4/IPv6
address. Nothing further is logged then.

On the client side, I get this message from the psql client when attempting to
connect via TCP to the server:

psql: error: server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.

Sometimes I'm lucky and the postgresql server dumps a core, without terminating
the whole postgresql service on the host.
A first investigation of the coredump with gdb and a backtrace seems to confirm
the problem with KTLS:

Reading symbols from /usr/local/bin/postgres...
(No debugging symbols found in /usr/local/bin/postgres)
[New LWP 252697]

warning: .dynamic section for "/lib/libc.so.7" is not at the expected address
(wrong library or version mismatch?)
Core was generated by `/usr/local/bin/postgres -D
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00000000006ae464 in secure_raw_write ()
(gdb) bt
#0  0x00000000006ae464 in secure_raw_write ()
#1  0x00000000006bab45 in ?? ()
#2  0x0000000800daeac0 in ?? () from /lib/libcrypto.so.111
#3  0x0000000800dadc79 in ?? () from /lib/libcrypto.so.111
#4  0x0000000800dadb76 in BIO_write () from /lib/libcrypto.so.111
#5  0x0000000800dabecb in ?? () from /lib/libcrypto.so.111
#6  0x0000000800dae2a8 in BIO_ctrl () from /lib/libcrypto.so.111
#7  0x0000000800c39b36 in ?? () from /usr/lib/libssl.so.111
#8  0x0000000800c46b47 in ?? () from /usr/lib/libssl.so.111
#9  0x0000000800c391c7 in ?? () from /usr/lib/libssl.so.111
#10 0x00000000006b9c19 in be_tls_open_server ()
#11 0x00000000006ae0bf in secure_open_server ()
#12 0x000000000075cc2f in ?? ()
#13 0x000000000075c375 in ?? ()
#14 0x000000000075bd13 in ?? ()
#15 0x000000000075910c in PostmasterMain ()
#16 0x00000000006bbd2c in main ()

I haven't enabled debugging on postgresql so far. Another server is also
running 14-CURRENT with KTLS enabled, but running postgresql12-server -
_without_ problems.

You are receiving this mail because:
You are the assignee for the bug.