The following bug has been logged on the website:
Bug reference: 16330
Logged by: Hugh Wang
Email address: hghwng@gmail.com
PostgreSQL version: 12.2
Operating system: Arch Linux
Description:
If the connection to postmaster is closed, then trying to re-connect to
another one leads to SIGSEGV.
REPRODUCE:
$ psql
-> \conninfo
You are connected to database "hugh" as user "hugh" via socket in
"/run/postgresql" at port "5432".
*shut down server with commands like "systemctl stop postgresql"*
-> \conninfo
You are currently not connected to a database.
-> \c a b c d
[1] 984978 segmentation fault (core dumped) psql
ANALYSIS:
PQhost(o_conn) returns NULL, and strcmp(host, NULL) raises SIGSEGV.
SOURCE:
https://github.com/postgres/postgres/blob/master/src/bin/psql/command.c#L3016