docs/findings.md, and the two siblings are 25 and 26.
All counts below are quoted from that finding and from the comment on MIN_GUEST_AGE_BEFORE_PAUSE in core/crates/vmm/src/vm/mod.rs. The runs were made on the one shared development box with a real Firecracker. Where a source gives a count and a different source gives it in other words, the post says so.
Problem and how it was found
The first sign was not a crash. It was a test that sometimes failed. The pool integration topic (18-pool) passed four of four times in isolation and failed once under the full suite running concurrently, with the check “deleting the pool cleaned up its own warm snapshot”. The daemon’s logs from the failing run showed pool-claim health checks reporting vsock ... Connection refused.
A pool claim resumes a pre-warmed snapshot and then runs a health check against the guest agent. “Connection refused” on vsock means nothing is listening on the guest’s side, which for a freshly resumed VM means either the agent has not started or the VM is gone. The claim path retries for its whole window, about 5 seconds, and then falls back to a cold create. So the user saw a slower create and a flaky test, not an error. Finding 10 recorded it as a probable resume-readiness race.
Reproducing it directly needed a loop that exercised exactly that path: create a sandbox, snapshot it, resume the snapshot, run a command. Running one at a time showed nothing. Running six in parallel did.
The first real clue
Every resume that failed had died. Firecracker itself had exited, about 0.55 seconds after the resume. It was not hung and not slow. The vsock calls were refused for the whole retry window because the process that owned the socket no longer existed. The second clue came from Firecracker’s log, which the daemon keeps per VM. Every failing resume logged one line at snapshot load:The experiments
With six snapshot-then-resume loops in parallel, the failure rate depended on one thing: how soon afterPOST /sandboxes returned the snapshot was taken.
That sweep is the evidence that this is a timing race and not a problem with snapshots in general. A snapshot of the same sandbox type, taken the same way, resumed under the same parallel load, never failed once any settling time was added, and failed about half the time without it. A bad code path in the resume would not care how old the guest was.
The timeline of one failing and one healthy case:
Why the exact state was never found
The finding states plainly what is known and what is not. The guest was paused while it was still settling right after its first command. The snapshot taken then lacks the guest clock state that Firecracker re-arms when it loads a snapshot, which is the thing theKVM_KVMCLOCK_CTRL call is for. When that call fails, the resumed VM dies shortly after.
What is not known is the guest-side state itself: which piece of the kvmclock handshake is incomplete at the instant of the pause. The finding records the next step if the crash ever recurs: capture a failing state.snap and compare it against a healthy one. Nothing in the evidence could be argued further than that, so nothing further is claimed.
What was wrong in the earlier theories
Two explanations were written down before the sweep and both were wrong.- “Kernel panic.” The first attribution was a guest kernel panic after resume. There was no panic text anywhere. A guest panic prints to the console log, which is captured per VM, and the log held no panic text. The VMM process simply exited, so there was nothing to support the attribution.
- “A TSC problem.” The clock line led to a guess about the timestamp counter. The finding records it as wrong about the mechanism. One reason it fits badly, by our reading, is the sweep: a mismatch between the host and the snapshot would not be expected to vanish after only 100 ms of extra guest runtime, and the failure rate tracked the guest’s age, not the host.
Root cause
A guest that has not been running for long is not in a state Firecracker can reliably snapshot for clock re-arming. The daemon asked it to pause the instant after create returned. At that point the guest is still initialising its clock source, and the snapshot taken there lacks state the load path depends on. The daemon created the situation itself.create returns as soon as Firecracker starts, and a snapshot request can arrive at any moment after that. Snapshotting a fresh sandbox is a legitimate thing to do, and nothing in the path knew the guest was not ready to be paused.
The change
Vm now records when it started running guest code, started_at, set at boot and again at resume. Vm::pause waits until the guest has been running for MIN_GUEST_AGE_BEFORE_PAUSE, which is 500 ms (core/crates/vmm/src/vm/snapshot.rs, pause).
Result
Three rounds of the same parallel loop against the fixed build, with no delay between create and snapshot (the case that used to fail half the time), killed none of 180 resumes. The full integration suite went from 343 of 346 checks to 345 of 346, and the one remaining miss was finding 25, covered next. The finding does not claim the18-pool flake is gone for good, only that the resume crash behind it is.
What it cost or risks
- A snapshot right after create is up to a few hundred milliseconds slower. Every other snapshot is unaffected. The pool’s warm-up pays it once per slot, off the user’s path.
- The cause is not fully understood. If a different workload leaves a guest in the bad state for longer than 500 ms, the failure would come back, and it would look the same: a resumed VM dying shortly after load with the clock line in its log. The finding says what to capture if it does.
- It fixed the resume, not every pool flake. Finding 27, an open one, is a bookkeeping race in pool slot accounting that showed up once in two full runs after this fix. It points at claim and release counters racing a fallback path, not at resume health.
Two sibling bugs found on the way
Looking at the pool path this closely turned up two more problems that were not the crash but would have made the story harder to read. Each is small enough for a short section.Finding 25: an MMDS call that could never work
When a pool snapshot is claimed, the sandbox needs its real id, name and tags in its metadata, which Firecracker serves from MMDS.Vm::update_metadata did this by re-applying PUT /mmds/config and then PUT /mmds, after every claim.
Firecracker rejects PUT /mmds/config once a VM has started, with “not supported after starting the microVM”. So the first call failed on every claim, the data was never written, and claimed sandboxes kept the pool’s placeholder metadata. It went unnoticed for two reasons: an old comment in the code blamed a load-related race for the failure, and a retry loop around the call hid it by trying again.
The fix is in core/crates/vmm/src/vm/mod.rs. The normal path writes only PUT /mmds, which a running VM accepts and which keeps the MMDS configuration restored from the snapshot. The configuration call remains only as a fallback if that write is refused. 18-pool passed three of three runs after it.
The root cause is a wrong assumption written down as a comment. A retry loop is only a fix for a transient failure, and this one was permanent. A retry that always fails and is then attributed to load is a bug with a good disguise.
Finding 26: the tunnel listener that leaked a thread and a descriptor
Each VM gets a tunnel listener, a Unix socket with an accept loop on its own thread. The loop never ended, andtunnel::cleanup only deleted the socket file, so each stopped VM left one thread blocked in accept and one open file descriptor behind.
After a few hundred VMs the daemon reached its 1024-descriptor soft limit and creates began failing with “Too many open files”, while the daemon reported zero live sandboxes. A leak that reports nothing live is easy to mistake for a limit problem.
The fix has two parts. First, cleanup now sets a stop flag for that listener and connects to its socket once to wake the blocked accept, so the thread sees the flag, exits and drops its listener (core/crates/vmm/src/tunnel.rs). A unit test proves the thread exits and the socket path is gone, using a counter of live listener threads. Second, the daemon raises its open-file soft limit to the hard limit at startup, before the async runtime starts (core/crates/daemon/src/rlimit.rs), because each live sandbox legitimately holds several descriptors and 1024 caps a busy host well below what it can serve.
Both are ownership bugs in the sense of the project’s rule that every resource needs a clear owner and a defined cleanup. The listener had a creator and no one to end it.
How to reproduce
The crash needs a real Firecracker. This loop recreates the failing case; run it against a build from before the change, or lowerMIN_GUEST_AGE_BEFORE_PAUSE temporarily on the box, since the current build waits.
died. Add sleep 0.2 after the create to see the count drop to zero. The signature in each failing VM’s Firecracker log is the KVM_KVMCLOCK_CTRL call failed line. If an auth token is configured, add the Authorization header to each call.