Lesson 12 of 13 · 15m
Core Dumps and Post-Mortems
ulimit, core_pattern, and coredumpctl turn a one-time segfault into a replayable debugging session — if you collected it first.
When a process dies on a signal whose default action is "Core" — SIGSEGV, SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGQUIT — the kernel can write its entire address space, registers, and per-thread state to a file. That file plus the binary plus its symbols is everything a debugger needs: the faulting instruction, the stack it ran on, every thread's state at the instant it died. The crash no longer has to be reproducible. The core is the reproduction.
Where the core goes
Two knobs decide whether you get one. ulimit -c is the size cap — set unlimited (or LimitCORE=infinity in a systemd unit). kernel.core_pattern is the destination: a plain path like /var/crash/core.%e.%p writes files directly, while a leading | pipes the dump to a program — which is what systemd hosts do: |/usr/lib/systemd/systemd-coredump ... stores dumps under /var/lib/systemd/coredump/, indexed. coredumpctl list shows the collection, coredumpctl info <pid> the report, coredumpctl debug opens gdb on it. Teams "have no core" for years because nobody checked the journal.
Reading it
gdb -batch -ex 'thread apply all bt' /path/to/binary /var/lib/systemd/coredump/core.*bt full gives locals, info registers the register file at fault, x/i $pc the instruction. gdb finds debug info via build-id when the distro -dbgsym/-dbg packages are installed — or via debuginfod, which fetches it over HTTP when DEBUGINFOD_URLS points at your distro's server (Ubuntu runs debuginfod.ubuntu.com). A core without symbols is a stack of addresses. Keep .debug files per release — objcopy --only-keep-debug plus --add-gnu-debuglink — so shipped binaries stay small while post-mortems stay possible.
For multi-threaded crashes, gdb opens on the faulting thread; thread apply all bt shows what everyone else held. A core where three threads wait on one mutex while a fourth died tells a different story than the segfault alone.
What's in one
readelf -n core dumps the ELF notes: NT_PRSTATUS per thread (registers and the killing signal — the fault address itself lives in NT_SIGINFO's si_addr, which gdb surfaces as $cr2), NT_AUXV with the auxiliary vector, NT_FILE mapping file-backed regions — which is how gdb knows which libc.so.6 the core's addresses belonged to. The mapped-file table also explains why a core can be smaller than RSS: file-backed pages resolve to the file, not the dump.
Two operational notes that bite people. Cores contain everything the process held — credentials, keys, user data — so they need 0600 permissions and a retention story, not a world-readable /tmp. And privilege-changing binaries refuse to dump by default: fs.suid_dumpable gates it, so a daemon that drops privileges can silently skip dumping unless you set it deliberately. On hosts running apport, crashes land as /var/crash/*.crash instead; apport-retrace unpacks them with symbols, and coredumpctl dump <pid> exports a stored dump for shipping to whoever owns the bug. Traditional-path setups that want per-PID files set kernel.core_uses_pid=1. Either way, test it once with kill -SEGV on a sacrificial process — the collection path that was never exercised is the one that fails during the incident.
From a live process
gcore -o /tmp/core <pid> snapshots a running process without killing it — for the hang, not the crash. eu-stack -p <pid> from elfutils prints every thread's stack in one shot with no debugger session; pstack does the same on older systems. For a wedged service the order matters: eu-stack for the instant picture, gcore for the archive, then restart. Restarting first deletes the evidence.
The practice
- Enable cores before the crash:
LimitCORE=infinityin the unit, a realcore_patterndirectory, disk budget for the dumps. - On systemd hosts,
coredumpctlfirst — the dump is almost always already collected. - Keep per-release debug symbols; wire
debuginfodwhere available. - For hangs:
eu-stack -p, thengcore, then restart — in that order.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Your Minecraft Server Isn't Slow, It's Misconfigured
Can't keep up! is not a hardware message. It's the server telling you a tick took longer than 50ms, and almost every cause is a default nobody changed. Here's what actually moves MSPT, with the flags that are now wrong and the setting that isn't where every guide says it is.
Your Minecraft Server Wants Java 25, Not Java 26
Every six months the same thread appears and nobody maps the JVM engineering onto what a Minecraft server actually does. This does — version by version, with the flag most guides still tell you to set that will eventually stop your server from booting.
Your Container Is Running SerialGC and Nobody Told You
You tuned G1 flags for a week. Your pod has one CPU, which means the JVM quietly picked a single-threaded collector at startup and ignored every flag you set. Here is the OpenJDK source that made that decision.
How to Debug Minecraft Server Lag with Spark Profiler (2026 Guide)
Your server dropped to 12 TPS. You copied Aikar's flags. You upgraded Java. Nothing changed. That's because JVM flags don't fix plugin bugs. Here's how to find what's actually killing your tick budget.