{"record":{"id":"56ffbb37ae973fc3","repo":"zellij-org/zellij","slug":"cannot-acquire-poisoned-lock-for-e","errorCode":null,"errorMessage":"cannot acquire poisoned lock for {e:#?}","messagePattern":"cannot acquire poisoned lock for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"zellij-utils/src/errors.rs","lineNumber":986,"sourceCode":"                            msg\n                        ))\n                        .with_context(|| context.to_string())\n                    } else {\n                        Err(anyhow::anyhow!(\"failed to send message to channel\"))\n                            .with_context(|| context.to_string())\n                    }\n                },\n            }\n        }\n    }\n\n    impl<U> ToAnyhow<U> for Result<U, std::sync::PoisonError<U>> {\n        fn to_anyhow(self) -> anyhow::Result<U> {\n            match self {\n                Ok(val) => anyhow::Ok(val),\n                Err(e) => {\n                    if *crate::consts::DEBUG_MODE.get().unwrap_or(&true) {\n                        Err(anyhow::anyhow!(\"cannot acquire poisoned lock for {e:#?}\"))\n                    } else {\n                        Err(anyhow::anyhow!(\"cannot acquire poisoned lock\"))\n                    }\n                },\n            }\n        }\n    }\n}\n","sourceCodeStart":968,"sourceCodeEnd":995,"githubUrl":"https://github.com/zellij-org/zellij/blob/bf8d23a4f774abf27a108da2a1a2689e7d8d0d23/zellij-utils/src/errors.rs#L968-L995","documentation":"Produced by the ToAnyhow impl for Result<_, std::sync::PoisonError<U>> when locking a std::sync::Mutex (or RwLock) whose poison flag is set: some thread panicked while holding the lock, so every subsequent .lock().to_anyhow() fails with this message. The DEBUG_MODE variant prints the PoisonError itself. It is always a secondary error — the original panic is the real fault.","triggerScenarios":"Any earlier panic inside a critical section (unwrapped Option/Result, index out of bounds, assertion) poisons the mutex; the next thread to acquire the lock gets Err(PoisonError) and converts it via to_anyhow(). In zellij this guards shared state like session/server bookkeeping.","commonSituations":"A rendering, input, or plugin thread panicked (often visible earlier in the log) and afterwards every user of that shared state reports 'cannot acquire poisoned lock'; typically the session becomes unresponsive and needs to be killed.","solutions":["Find the FIRST panic in the log/backtrace (RUST_BACKTRACE=1) — fix or report that; the poison message only tells you which lock was held.","Kill and restart the wedged session (zellij kill-session <name>) — poisoned state does not recover in-process.","If reproducible, reduce to the key/mouse sequence or layout that triggers the original panic and file an upstream issue with both backtraces.","Update zellij — the panic that poisons the lock is usually already fixed."],"exampleFix":"// before: panic while holding the lock poisons it for everyone\nlet state = shared.lock().unwrap();\ndo_work_that_may_panic(&state); // panic here poisons the mutex\n\n// after: keep panics out of the critical section\nlet snapshot = shared.lock().unwrap().clone();\ndo_work_that_may_panic(&snapshot); // lock already released","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// recovering shared state after poisoning (data may be mid-update: validate!)\nlet guard = match mutex.lock() {\n    Ok(g) => g,\n    Err(poisoned) => {\n        log::error!(\"mutex poisoned by earlier panic; recovering guard\");\n        poisoned.into_inner()\n    },\n};","preventionTips":["Never panic inside a critical section: clone data out of the lock and do fallible work after releasing it.","Prefer lock scopes measured in statements; avoid .unwrap()/.expect()/indexing while holding the mutex.","Hunt the FIRST panic in logs whenever a poison error appears — the lock message is only the echo."],"tags":["zellij","rust","mutex","poisoned-lock","panic"],"backgroundTag":"mutex-poisoned","analyzedSha":"bf8d23a4f774abf27a108da2a1a2689e7d8d0d23","analyzedAt":"2026-08-19T07:42:58.758Z","contentChangedAt":"2026-08-19T07:42:58.758Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}