Subject: Re: segmentation fault

From: Tom Lane <[email-masked]>
Date: Wed, 23 Apr 2025 15:23:20 -0400

"Zechman, Derek S" <[email-masked]> writes:
> We are getting a segmentation fault which seems to be specific to pg16 on redhat 8.  Tested on pg14 and pg15 with no problems.  Also tested with pg16 on redhat 9 - no issues.  The developer determined that it is specific to select into a defined variable within a function.  We have a reproducible test case that requires no data.  I determined that 2857 is the maximum number that doesn't crash and anything higher than that causes a segfault.  Can anyone help with this problem?

FWIW, I cannot replicate this problem using this script.  Now I'm
testing v16 branch tip not 16.6, but a quick trawl through the git
history didn't find any plausibly-matching bug fixes since 16.6.

Where did you get your Postgres server executable from exactly,
and what options was it built with?  (The output of the matching
version of pg_config would answer that.)  Can you get a stack
trace from the crash?

https://wiki.postgresql.org/wiki/Generating_a_stack_trace_of_a_PostgreSQL_backend

			regards, tom lane

---

From: "Zechman, Derek S" <[email-masked]>
Date: Wed, 23 Apr 2025 20:59:28 +0000

We got it from pgdg repository.

Here is the output of pg_config is below.  We have been struggling to get a stack trace, however – since we couldn’t reproduce it with a vanilla installation and neither could you – we determined it must be something specific to our environment.   Turns out when pg_show_plan is in the shared_preload_libraries then we get a segmentation fault.  I checked the github repo from cybertec and surprised there have been no reported issues with it.  I will be posting there shortly.

BINDIR = /usr/pgsql-16/bin
DOCDIR = /usr/pgsql-16/doc
HTMLDIR = /usr/pgsql-16/doc/html
INCLUDEDIR = /usr/pgsql-16/include
PKGINCLUDEDIR = /usr/pgsql-16/include
INCLUDEDIR-SERVER = /usr/pgsql-16/include/server
LIBDIR = /usr/pgsql-16/lib
PKGLIBDIR = /usr/pgsql-16/lib
LOCALEDIR = /usr/pgsql-16/share/locale
MANDIR = /usr/pgsql-16/share/man
SHAREDIR = /usr/pgsql-16/share
SYSCONFDIR = /etc/sysconfig/pgsql
PGXS = /usr/pgsql-16/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE =  '--enable-rpath' '--prefix=/usr/pgsql-16' '--includedir=/usr/pgsql-16/include' '--mandir=/usr/pgsql-16/share/man' '--datadir=/usr/pgsql-16/share' '--libdir=/usr/pgsql-16/lib' '--with-lz4' '--with-zstd' '--enable-tap-tests' '--with-icu' '--with-llvm' '--with-perl' '--with-python' '--with-tcl' '--with-tclconfig=/usr/lib64' '--with-openssl' '--with-pam' '--with-gssapi' '--with-includes=/usr/include' '--with-libraries=/usr/lib64' '--enable-nls' '--enable-dtrace' '--with-uuid=e2fs' '--with-libxml' '--with-libxslt' '--with-ldap' '--with-selinux' '--with-systemd' '--with-system-tzdata=/usr/share/zoneinfo' '--sysconfdir=/etc/sysconfig/pgsql' '--docdir=/usr/pgsql-16/doc' '--htmldir=/usr/pgsql-16/doc/html' 'CFLAGS=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' 'LDFLAGS=-Wl,--as-needed' 'LLVM_CONFIG=/usr/bin/llvm-config-64' 'CLANG=/usr/bin/clang' 'PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'
CC = gcc
CPPFLAGS = -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
CFLAGS_SL = -fPIC
LDFLAGS = -Wl,--as-needed -L/usr/lib64 -L/usr/lib -L/usr/lib64 -Wl,--as-needed -Wl,-rpath,'/usr/pgsql-16/lib',--enable-new-dtags
LDFLAGS_EX =
LDFLAGS_SL =
LIBS = -lpgcommon -lpgport -lselinux -lzstd -llz4 -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -lreadline -lpthread -lrt -ldl -lm
VERSION = PostgreSQL 16.8

From: Tom Lane <[email-masked]>
Sent: Wednesday, April 23, 2025 3:23 PM
To: Zechman, Derek S <[email-masked]>
Cc: [email-masked]
Subject: Re: segmentation fault

"Zechman, Derek S" <Derek. S. Zechman@ snapon. com> writes: > We are getting a segmentation fault which seems to be specific to pg16 on redhat 8. Tested on pg14 and pg15 with no problems. Also tested with pg16 on redhat 9 - no issues. The

trace from the crash?

https://urldefense.com/v3/__https://wiki.postgresql.org/wiki/Generating_a_stack_trace_of_a_PostgreSQL_backend__;!!Lf_9VycLqA!lHekhKzAMOJ0nurE4gyelvKXRrULtGMRcKK1c_skYs_MZphlwF859-tyK5-8UjeYq2uE1oJb5OLpUFxi4DOF$<https://urldefense.com/v3/__https:/wiki.postgresql.org/wiki/Generating_a_stack_trace_of_a_PostgreSQL_backend__;!!Lf_9VycLqA!lHekhKzAMOJ0nurE4gyelvKXRrULtGMRcKK1c_skYs_MZphlwF859-tyK5-8UjeYq2uE1oJb5OLpUFxi4DOF$>

                                              regards, tom lane