Two months. Twenty-three coredumps. Every one of them faithfully written to /var/cores by the kernel, every one loaded cleanly by gdb, and every one said the same thing:
(gdb) bt
#0 0x00007f8c4a112c43 in ?? ()
#1 0x00007f8c4a1129ff in ?? ()
#2 0x00007f8c00000000 in ?? ()
#3 0x0000000000000000 in ?? ()
Twenty-three coredumps. Twenty-three columns of question marks.
The service was a log router. It received UDP datagrams from about a hundred machines, parsed them, tagged them with metadata, and forwarded them over TCP to three downstream aggregators. Eighteen months without a problem. Then it started dying, once or twice a week, always SIGSEGV, always with a core.
Not frequent enough to declare an incident. Frequent enough that the supervisor was restarting it every few days while everyone quietly wondered what was going on. Two months of that while we were busy with other things.
When I finally sat down with one of the cores, I had twenty-three of them waiting.
$ gdb /usr/sbin/logrouted /var/cores/core.logrouted.23847
...
Core was generated by `/usr/sbin/logrouted --config /etc/logrouted.conf'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f8c4a112c43 in ?? ()
(gdb) bt full
#0 0x00007f8c4a112c43 in ?? ()
No symbol table info available.
No symbol table info. Right.
$ file /usr/sbin/logrouted
/usr/sbin/logrouted: ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, stripped
Stripped. Of course it was stripped. We stripped it ourselves, in the install target of the Makefile, because that is what you do in production. Smaller binary. Faster startup. Twenty years of habit.
A stripped binary has no symbol table. No symbol table means gdb cannot map instruction addresses to function names. ?? is gdb’s way of saying: I have an address, I have no idea what function it belongs to, I cannot tell you anything about this frame.
That part I knew. What I had not fully internalized was how badly -fomit-frame-pointer makes things worse on top of that.
Frame pointers are optional. The frame pointer register (rbp on x86-64) maintains a linked list of stack frames. Each function, on entry, pushes the previous frame pointer and sets rbp to point at the current frame. When you unwind the stack, you walk this list: current frame, parent frame, grandparent, all the way up to main. It is how gdb, backtrace(3), and every conventional stack unwinder navigates the chain.
-fomit-frame-pointer is a standard optimization flag that frees rbp for use as a general-purpose register. On x86-64 with only sixteen general-purpose registers that is a real gain, and gcc and clang include it in -O2 by default. Most production builds get it without anyone consciously choosing it.
When you have debug symbols, this is not a problem. DWARF call frame information records enough state to unwind the stack without a frame pointer. The compiler emits this as .eh_frame and .debug_frame sections. Unwinders read them.
When you strip the binary, the DWARF information goes away. Now you have no frame pointer and no DWARF call frame data. The unwinder has nothing. You get ??.
I had twenty-three cores and no way to read any of them.
The fix, once you understand the problem, is one of three things.
Keep the unstripped binary in your artifact store. You do not need to ship it to production. Ship the stripped binary to the box, keep a fat binary in your build artifacts for the lifetime of that release. When a core lands, copy it off the box and load it with the unstripped binary locally:
$ gdb /path/to/build/logrouted.unstripped /tmp/core.logrouted.23847
gdb loads symbols from the binary, not from the running system. You also need the matching unstripped shared libraries, which is where debuginfo packages come in on rpm-based distros, and *-dbg packages on Debian. For your own code, keeping the unstripped binary in CI artifacts is enough.
Produce a separate debuginfo file. This is what distros do for their own packages. A stripped binary contains a .gnu_debuglink section or a NT_GNU_BUILD_ID note recording a hash of the binary contents. gdb checks /usr/lib/debug/ for a matching .debug file with the same build ID. If it finds one, it loads symbols from there, transparently, without you having to remember where the artifacts are.
You can do this yourself with eu-strip from elfutils:
$ eu-strip --strip-debug -f logrouted.debug logrouted
This produces two files: logrouted stripped and ready for production, and logrouted.debug with only the symbol and DWARF data. Put the .debug file at /usr/lib/debug/usr/sbin/logrouted.debug on any machine where you do postmortem debugging, and gdb finds it automatically by build ID.
Strip the symbol table but keep the DWARF frames. You can strip away most of the debug bulk while keeping just enough for stack unwinding:
$ strip --strip-unneeded logrouted
--strip-unneeded removes the symbol table and other non-essential sections but preserves .eh_frame. The resulting binary is still meaningfully smaller than an unstripped one, and frame unwinding still works without the frame pointer register. You get function names if the shared libraries have symbols, and you get something better than ?? either way.
I went back through the twenty-three cores with the unstripped binary from the build server.
Core number seven had a clean stack trace. A use-after-free in the tag metadata path: a pointer to a struct allocated in the request handler was being cached, the struct was freed when the request completed, and the pointer was dereferenced after that in a code path that ran under higher load. Classic. The crash happened when the freed memory was reused by something else, the four-byte magic number at the start of the struct no longer matched, and the code treating it as live data walked off somewhere bad.
The bug had been in the code for eight months. We introduced it in a refactor that moved ownership of the tag struct from the connection context to the request context, and nobody caught that the metadata cache still held a reference.
Twenty-three crashes. Two months. All the evidence we needed was sitting in /var/cores the whole time. We had thrown away the key in the build system.
The build ID mechanism is worth knowing about even if you do not use debuginfo packages. Every ELF binary compiled with a reasonably recent toolchain has a NT_GNU_BUILD_ID note section. Check it:
$ eu-readelf -n /var/cores/core.logrouted.23847 | grep Build
Build ID: 4c6f47c2d91a7e0b3f8a1c5e2d4b9f8a1c5e2d4b
That ID is stable for a given binary. If your CI system archives the unstripped binary or the .debug file with that ID as part of the file name, retrieval is unambiguous. A crash from six months ago, on a version that has been replaced twice, still has a unique key to the exact debug info you need.
The same ID is in the core file itself, which the kernel writes automatically. You do not need to do anything special to record which binary crashed. The binary told you when it was compiled.
This pattern is how the reliability-observability cases in the worst category end: not because we lacked monitoring or alerting or logging, but because the artifact that would have told us what happened had been deliberately cleaned up before we needed it. The pipeline that succeeded in silence is a different flavor of the same failure, where the evidence of what went wrong was discarded before anyone thought to check it.
I have been stripping production binaries since before most of the people I work with were writing code. I will keep doing it. But now I keep the unstripped binary in the artifact store for the lifetime of the build, and the release process uses eu-strip to produce a separate .debug file that goes into the debuginfo directory on any box used for postmortem work.
Strip your binaries. Keep the symbols somewhere you can find them.
