Skip to content

Instantly share code, notes, and snippets.

@cabecada
Last active June 28, 2021 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cabecada/63daaf257dd3bcf29fa4b106465fd65b to your computer and use it in GitHub Desktop.
Save cabecada/63daaf257dd3bcf29fa4b106465fd65b to your computer and use it in GitHub Desktop.
core dump
https://ngelinux.com/how-to-enable-core-dump-collection-in-linux-for-every-user/#:~:text=%20Enabling%20Core%20dump%20in%20Linux.%20%201,core%20unlimited%E2%80%9D%20to%20enable%20the%20core...%20More%20
postgres@db:~/playground/logical_replication$ ulimit -a
core file size (blocks, -c) 0
as root
printf "* soft core unlimited\n" >> /etc/security/limits.conf
postgres@db:~/playground/logical_replication$ sudo vim /etc/security/limits.conf
postgres@db:~/playground/logical_replication$ ulimit -c
0
postgres@db:~/playground/logical_replication$ ulimit -c 102400
postgres@db:~/playground/logical_replication$ ulimit -c
102400
where to dump to
postgres@db:~/playground/logical_replication$ sudo sysctl -w kernel.core_pattern=/var/crash/core.%u.%e.%p
kernel.core_pattern = /var/crash/core.%u.%e.%p
postgres@db:~/playground/logical_replication$ sudo cat /proc/sys/kernel/core_pattern
/var/crash/core.%u.%e.%p
postgres@db:~/playground/logical_replication$ pg_ctl -D example start
waiting for server to start....2021-06-28 12:26:08.784 IST [1548] LOG: 00000: starting PostgreSQL 14beta1 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, 64-bit
2021-06-28 12:26:08.784 IST [1548] LOCATION: PostmasterMain, postmaster.c:1128
2021-06-28 12:26:08.784 IST [1548] LOG: 00000: listening on IPv4 address "127.0.0.1", port 5432
2021-06-28 12:26:08.784 IST [1548] LOCATION: StreamServerPort, pqcomm.c:582
2021-06-28 12:26:08.790 IST [1548] LOG: 00000: listening on Unix socket "/tmp/.s.PGSQL.5432"
2021-06-28 12:26:08.790 IST [1548] LOCATION: StreamServerPort, pqcomm.c:577
2021-06-28 12:26:08.800 IST [1549] LOG: 00000: database system was shut down at 2021-06-27 21:32:14 IST
2021-06-28 12:26:08.800 IST [1549] LOCATION: StartupXLOG, xlog.c:6492
2021-06-28 12:26:08.818 IST [1548] LOG: 00000: database system is ready to accept connections
2021-06-28 12:26:08.818 IST [1548] LOCATION: reaper, postmaster.c:3042
done
server started
postgres@db:~/playground/logical_replication$ kill -ABRT 1548
postgres@db:~/playground/logical_replication$ sudo ls /var/crash/
core.1000.postgres.1548
################################# then sample gdb run
root@db:~# gdb /home/postgres/pgsql/bin/postgres /var/crash/core.1000.postgres.1548
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/pgsql/bin/postgres...
[New LWP 1548]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/home/postgres/pgsql/bin/postgres -D example'.
Program terminated with signal SIGABRT, Aborted.
#0 0x00007fe17fa370da in __GI___select (nfds=nfds@entry=7, readfds=readfds@entry=0x7fff7fb8d3f0, writefds=writefds@entry=0x0,
exceptfds=exceptfds@entry=0x0, timeout=timeout@entry=0x7fff7fb8d340) at ../sysdeps/unix/sysv/linux/select.c:41
41 ../sysdeps/unix/sysv/linux/select.c: No such file or directory.
(gdb) bt
#0 0x00007fe17fa370da in __GI___select (nfds=nfds@entry=7, readfds=readfds@entry=0x7fff7fb8d3f0, writefds=writefds@entry=0x0,
exceptfds=exceptfds@entry=0x0, timeout=timeout@entry=0x7fff7fb8d340) at ../sysdeps/unix/sysv/linux/select.c:41
#1 0x000055acbd55776c in ServerLoop () at postmaster.c:1709
#2 0x000055acbd5590bf in PostmasterMain (argc=<optimized out>, argv=0x55acbf11ef30) at postmaster.c:1417
#3 0x000055acbd2eecd2 in main (argc=3, argv=0x55acbf11ef30) at main.c:209
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment