fix(hypervisors): treat zombie VMM as dead in killProcess to avoid 2s deadlock#812
Open
Atishyy27 wants to merge 1 commit into
Open
fix(hypervisors): treat zombie VMM as dead in killProcess to avoid 2s deadlock#812Atishyy27 wants to merge 1 commit into
Atishyy27 wants to merge 1 commit into
Conversation
… deadlock killProcess sends SIGKILL and then polls unix.Kill(pid, 0) until it returns ESRCH. However, once a VMM (Firecracker/QEMU/HVT/...) terminates it becomes a zombie until its parent (the containerd shim) reaps it, and unix.Kill(pid, 0) keeps returning nil for a zombie. The loop therefore never observed the process dying and burned the full 2s timeout on every forced cleanup path (e.g. urunc delete --force), then returned a bogus "timeout waiting for pid to die" error. Detect the zombie (Z) state via /proc/<pid>/stat and treat it as dead, so cleanup returns immediately. The stat parsing is split into a pure statIsZombie() helper (handles a comm field containing spaces or ')') and unit tested. Fixes urunc-dev#790
✅ Deploy Preview for urunc canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #790.
When a VMM (Firecracker/QEMU/HVT/SPT/Cloud Hypervisor) terminates it enters the zombie (defunct) state until its parent — the containerd shim — reaps it with
waitpid.killProcesssendsSIGKILLand then pollsunix.Kill(pid, 0)waiting forESRCH:unix.Kill(pid, 0)returns nil for a zombie (it still exists in the process table), so the loop never seesESRCH. Every forced-cleanup path (e.g.urunc delete --force) therefore blocks for the full 2-second timeout and then returns a bogus"timeout waiting for pid to die"error, even though the VMM is already dead.Fix
Detect the zombie state via
/proc/<pid>/statand treat it as dead, breaking out of the loop immediately:isZombie(pid)reads the stat file (missing file → already reaped → treated as gone).statIsZombie([]byte)is a pure helper that reads the process state field. It parses the state as the first byte after the final), so acommfield containing spaces or)cannot corrupt parsing.Result: forced cleanup returns as soon as the VMM is dead instead of waiting ~2000 ms, and no longer reports a false timeout error.
Tests
TestStatIsZombiecovers zombie/running/sleeping states, acommwith embedded spaces and), and malformed/empty input.Verification
go build,go vetand test compilation pass (cross-compiled tolinux/amd64). The purestatIsZombielogic was also run directly against all test cases. CI will run the full suite on Linux.