{"record":{"id":"67f26200168d48bc","repo":"firecracker-microvm/firecracker","slug":"timed-out-waiting-for-vcpu-thread-name-to-exit","errorCode":null,"errorMessage":"Timed out waiting for vCPU thread '{name}' to exit","messagePattern":"Timed out waiting for vCPU thread '(.+?)' to exit","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/vmm/src/vstate/vcpu.rs","lineNumber":660,"sourceCode":"    }\n}\n\n// Wait for the Vcpu thread to finish execution\nimpl Drop for VcpuHandle {\n    fn drop(&mut self) {\n        // The vCPU thread owns the response sender, so the channel disconnects\n        // once it exits. Wait for that disconnect (draining any stale responses)\n        // with a timeout rather than joining unconditionally, so a thread that\n        // never finished (e.g. a missed Finish event) fails fast instead of\n        // hanging teardown forever.\n        let thread = self.vcpu_thread.take().unwrap();\n        loop {\n            match self.response_receiver.recv_timeout(VCPU_JOIN_TIMEOUT) {\n                // Sender dropped: the thread has exited.\n                Err(RecvTimeoutError::Disconnected) => break,\n                Err(RecvTimeoutError::Timeout) => {\n                    let name = thread.thread().name().unwrap_or(\"<unnamed>\");\n                    panic!(\"Timed out waiting for vCPU thread '{name}' to exit\")\n                }\n                // Unexpected: a response was still queued at teardown. Discard\n                // it and keep waiting for the thread to exit.\n                Ok(response) => {\n                    warn!(\"Discarding unexpected vCPU response during teardown: {response:?}\");\n                }\n            }\n        }\n        thread.join().unwrap();\n    }\n}\n\n/// Vcpu emulation state.\n#[derive(Debug, Copy, Clone, PartialEq, Eq)]\npub enum VcpuEmulation {\n    /// Handled.\n    Handled,\n    /// Interrupted.","sourceCodeStart":642,"sourceCodeEnd":678,"githubUrl":"https://github.com/firecracker-microvm/firecracker/blob/81b38b9dad6056d7a48073e95ac5a9aed51cb2ab/src/vmm/src/vstate/vcpu.rs#L642-L678","documentation":"Error \"Timed out waiting for vCPU thread '{name}' to exit\" thrown in firecracker-microvm/firecracker.","triggerScenarios":"Thrown at src/vmm/src/vstate/vcpu.rs:660 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Investigate why the named vCPU thread did not exit; check for a stuck KVM_RUN or guest hang.","Fix the hang rather than increasing the shutdown timeout, unless the vCPU is provably making progress."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"81b38b9dad6056d7a48073e95ac5a9aed51cb2ab","analyzedAt":"2026-08-19T05:27:02.517Z","contentChangedAt":"2026-08-19T05:27:02.517Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}