Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
pg core dump
# i modified https://github.com/postgres/postgres/blob/7c44c46deb495a2f3861f402d7f2109263e3d50a/src/backend/access/common/heaptuple.c#L94
to
if (att->atthasmissing) -> if (! att->atthasmissing)
# https://www.highgo.ca/2019/10/03/trace-query-processing-internals-with-debugger/
recompiled and make install
./configure --prefix /home/postgres/example/pgsql --enable-debug 2>&1 >/dev/null
make install
then ran the test to reproduce
# https://github.com/postgres/postgres/blob/7c44c46deb495a2f3861f402d7f2109263e3d50a/src/test/regress/expected/fast_default.out
postgres@db:~/example$ ulimit -c
unlimited
postgres@db:~/example$ export PATH=/home/postgres/.pyenv/shims:/home/postgres/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/postgres/example/pgsql/bin
postgres@db:~/example$ pg_ctl -D example -l logfile stop waiting for server to shut down.... done
server stopped
postgres@db:~/example$ pg_ctl -D example -l logfile start
waiting for server to start.... done
server started
postgres@db:~/example$ psql
psql (13.3)
Type "help" for help.
postgres=# drop table t1;
DROP TABLE
postgres=# CREATE TABLE t1 AS
SELECT 1::int AS a , 2::int AS b
FROM generate_series(1,20) q;
SELECT 20
postgres=# ALTER TABLE t1 ADD COLUMN c text;
ALTER TABLE
postgres=# SELECT a,
stddev(cast((SELECT sum(1) FROM generate_series(1,20) x) AS float4))
OVER (PARTITION BY a,b,c ORDER BY b)
AS z
FROM t1;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.
postgres=# \q
postgres@db:~/example$ ls -lrt
total 175612
drwx------ 19 postgres postgres 4096 Jun 30 14:20 example
-rw------- 1 postgres postgres 151969792 Jun 30 14:20 core.1000.postgres.23620
postgres@db:~/example$ chmod a+rwx core.1000.postgres.23620
postgres@db:~/example$ sudo gdb /home/postgres/example/pgsql/bin/postgres /home/postgres/example/core.1000.postgres.23620
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 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 "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/postgres/example/pgsql/bin/postgres...
[New LWP 23620]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `postgres: postgres postgres [local] SELECT '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000055b0342c3771 in getmissingattr () -- right at the place where i made that change
(gdb) bt
#0 0x000055b0342c3771 in getmissingattr ()
#1 0x000055b0346c0f4f in comparetup_heap ()
#2 0x000055b0346bddad in qsort_tuple ()
#3 0x000055b0346c3768 in tuplesort_performsort ()
#4 0x000055b034464038 in ExecSort ()
#5 0x000055b034467ff0 in begin_partition ()
#6 0x000055b03446b3b5 in ExecWindowAgg ()
#7 0x000055b0344389a3 in standard_ExecutorRun ()
#8 0x000055b03458f4bc in PortalRunSelect ()
#9 0x000055b0345906be in PortalRun ()
#10 0x000055b03458c42c in exec_simple_query ()
#11 0x000055b03458e012 in PostgresMain ()
#12 0x000055b034519fcf in ServerLoop ()
#13 0x000055b03451af2b in PostmasterMain ()
#14 0x000055b0342bacf2 in main ()
(gdb) quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment