Core Dump: Analyze a Running Process with gcore

Quick Linux Tip #92:

Question: A process is misbehaving. Can I dump its memory for post-mortem analysis?

Try: sudo gcore -o /tmp/mysqld_dump 3456

Info: gcore generates a core dump of a running process without terminating it. The resulting core snapshot can be analyzed offline using gdb.

Examples:

  • $ sudo gcore 3456  # Dumps process memory to current working directory
  • $ coredumpctl list  # List historical system core dumps
  • $ coredumpctl debug 3456  # Load crash core directly into gdb debugger

Note: Core dumps equal full process RAM usage and can be large—compress with gzip. Meaningful stack traces require matching binaries and unstripped debug symbols.



LinuxTeck.com
linuxteck:~$ sudo gcore -o /tmp/mysqld_dump 3456
0x00007f8a1234abcd in poll () from /lib/x86_64-linux-gnu/libc.so.6
Saved corefile /tmp/mysqld_dump.3456

linuxteck:~$ ls -lh /tmp/mysqld_dump.3456
-rw-r--r-- 1 root root 2.3G Oct 06 09:34 /tmp/mysqld_dump.3456

linuxteck:~$ sudo gdb /usr/sbin/mysqld /tmp/mysqld_dump.3456 -ex 'bt' -batch
#0  0x00007f8a1234abcd in poll () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x0000555512345 in handle_connections () at sql_connect.cc:1234
#2  0x000055551a4b6 in main () at mysqld.cc:5678
linuxteck:~$

PREVIOUS ARTICLE Quick Linux Tip #91: Open Ports: Find Which Program Uses Them in Linux NEXT ARTICLE Quick Linux Tip #93: Strace -c Command: Find Slow System Calls in Linux
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.