techlist.io

Core Dumps

1 posts

OpenAI2026-06-293 min readCurated summary

Core dump epidemiology: fixing an 18-year-old bug

# Libunwind Race Condition and a Bad Host Behind Rockset's Mysterious Crashes OpenAI's Rockset service, a C++ data system that powers ChatGPT's search over connectors and conversations, began crashing with stacks that appeared to return to invalid addresses or to have a misaligned stack pointer. The author's team initially treated these as one impossible bug. A population-level analysis of core dumps revealed they were two unrelated problems: silent hardware corruption on a single Azure host, and an 18-year-old race condition in GNU libunwind that surfaces during C++ exception unwinding. The main lesson is that building a clean data set about the whole crash population was what made the diagnosis tractable. ## Two Crash Populations Hiding in One Symptom - Return-to-null crashes were spread across many clusters and regions, with no clean start date. - Misaligned-stack crashes came from one region, began on a specific date, and never occurred on long-running nodes, pointing to a single physical machine. - Earlier counterexamples that seemed to rule out exception unwinding came from the hardware cluster, which made the team's conclusions backward. ## Building a Population Dataset - The team had a script, written with ChatGPT, that downloaded the start of each core file, extracted registers, filtered false positives using logs, and labeled each crash as return-to-null, misaligned-stack, or other. - It ran in parallel across every production core dump from the previous year. - Log-based text searches had produced both false positives and false negatives, and manual inspection did not scale. ## Bug #1: A Bad Host - The misaligned-stack crashes traced to one physical Kubernetes node, which was denylisted. - Stress testing could not reproduce the register corruption, even after weeks. - Mitigations included adding register state to the fatal signal handler so recurrence can be spotted from logs, and reusing VMs rather than recycling them so bad nodes are easier to detect. ## Bug #2: A Libunwind Race in Exception Unwinding - C++ exception unwinding works like a longjmp: runtime helpers restore callee-saved registers, `%rbp`, and `%rsp` to transfer control to a catch block or cleanup handler. - The binary linked against both libgcc and GNU libunwind, and the dynamic linker selected libunwind's implementation. - Libunwind synthesizes a `ucontext_t` on the stack and passes it to `_Ux86_64_setcontext`. - The routine updates `%rsp` before it finishes reading the struct. In that window, a signal delivered by the kernel builds its frame at `%rsp-128` and can overwrite the struct, so the restored instruction pointer becomes NULL. - The race window is a single instruction, roughly a hundred picoseconds. A Fermi estimate still explained the observed rate: Rockset throws about 10⁴ exceptions per second for backpressure, and it delivers SIGUSR2 frequently through its coarse CPU-time clock. - The bug had existed since the first x86_64 version of libunwind's C++ unwinding support. It became visible only after the team increased exception and signal rates and added a `timer_getoverrun` call to the SIGUSR2 handler, which enlarged the handler's stack usage. ## Mitigation and Takeaways - The team switched from GNU libunwind to libgcc's unwinder, which also reduces lock contention on large VMs. - They upstreamed a reproducer and fix to GNU libunwind and confirmed that the other unwinders do not share the issue. - The central lesson is that high-quality population data separated two mixed phenomena and made the rest of the debugging straightforward. For infrastructure systems, this supports investing in deep instrumentation, automated investigation pipelines, and operational tooling.