Where are my core dump files?

One day, on a Ubuntu 22.04 machine, I had to debug my application which segfaults with messages like: corrupted double-linked list or free(): corrupted unsorted chunks.

I could see an error message:

[1]    123456 abort (core dumped)  my_faulty_application

but could not find the corresponding core dump file anywhere.

Where is it?


Ubuntu and core dumps

After some googling, I could find some articles saying that core dumps are handled by Apport in Ubuntu, but they are not enabled in stable releases.

There were a few solutions for this, and I chose to install systemd-coredump:

$ sudo apt-get install systemd-coredump

Generating core dumps

After installing systemd-coredump, and running my faulty application, it finally generated a core dump file.

I could find it in /var/lib/systemd/coredump/:

$ ls /var/lib/systemd/coredump/

core.my_faulty_application.9999.abcdefghijklmnopqrstuvwxyz012345.123456.0000000000000000.zst

Using the core dump file

List the dumped files,

$ coredumpctl list

TIME                           PID  UID  GID SIG     COREFILE EXE                            SIZE
Thu 2022-11-10 15:59:05 KST 123456 9999 9999 SIGABRT present  /path/to/my_faulty_application 2.0M

dump desired one into the current directory,

$ coredumpctl dump 123456 --output ./coredump

and debug it with:

$ gdb /path/to/my_faulty_application ./coredump

or debug directly with coredumpctl:

$ coredumpctl debug 123456

Clean up unused core dump files

Unused core dump files can be deleted at once with:

$ sudo rm /var/lib/systemd/coredump/core.*.zst

then they will be displayed as ‘missing’ on coredumpctl list.


Wrap-Up

Some linux distributions don’t enable core dumps due to security or storage issues.

When needed, they can be enabled and help debugging things.