BigPizzaV3/CodexPlusPlus · error
Remote Control recovery state lock poisoned
Error message
Remote Control recovery state lock poisoned
What it means
load_pending_remote_control_recoveries reads the persisted Remote Control recovery state under a process-wide mutex. If a thread panicked while holding that mutex (e.g. a bug in load_state or serialization), the RwLock/Mutex is poisoned and every later .lock() returns Err. The library converts that into this anyhow error instead of silently proceeding with possibly-corrupt state.
Solutions
- Find and fix the code that panicked while holding the state lock (panic is the root cause, poisoning is the symptom).
- Wrap lock-internal code in catch_unwind or avoid panicking operations (use map_err instead of unwrap) inside the critical section.
- Replace state_lock() with a poisoning-resistant primitive such as parking_lot::Mutex, or call lock().unwrap_or_else(|p| p.into_inner()) if state corruption is acceptable.
- Restart the process; poisoning is per-lock-instance so a restart clears it.
Example fix
// before
let _guard = state_lock().lock().map_err(|_| anyhow::anyhow!("Remote Control recovery state lock poisoned"))?;
// after
let _guard = state_lock().lock().unwrap_or_else(|poisoned| poisoned.into_inner()); Defensive patterns
Strategy: try-catch
Validate before calling
// No pre-check possible for poisoning; ensure prior calls didn't panic
// e.g. assert_no_poison: run a cheap lock probe
let probe = state_lock().lock();
if probe.is_err() { /* lock poisoned: restart or recover before calling API */ } Try / catch
match load_pending_remote_control_recoveries(None) {
Ok(requests) => requests,
Err(e) if e.to_string().contains("lock poisoned") => {
// log original panic source, recover state via into_inner or restart
Vec::new()
}
Err(e) => return Err(e),
} Prevention
- Never panic (unwrap/expect) inside code holding the recovery state lock.
- Consider parking_lot::Mutex to avoid poisoning semantics.
- Keep lock critical sections small and infallible.
- Log panics with backtrace to identify the poisoning culprit quickly.
When it happens
Trigger: Calling load_pending_remote_control_recoveries after any earlier thread panicked while holding state_lock(); concurrent access where one closure panics (e.g. unwrapping a bad path) between enqueue and load.
Common situations: Long-running manager app where a background thread panicked in a recovery helper earlier in the session; tests that panic inside a closure holding the lock and then re-call the API.
Related errors
- 微信连接运行锁已损坏
- rollout changed before rollback
- archived lookup task failed
- bridge context lock poisoned
- built-in Dream Skin theme cannot be deleted
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/7ea05fe0be3b14a1.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/remote_control_recovery.rs:53
}
pub fn config_generation(profile: &RelayProfile, target_provider: &str) -> String {
let mut digest = Sha256::new();
digest.update(profile.id.trim().as_bytes());
digest.update([0]);
digest.update(profile.config_contents.as_bytes());
digest.update([0]);
digest.update(target_provider.trim().as_bytes());
format!("{:x}", digest.finalize())
}
pub fn load_pending_remote_control_recoveries(
path: Option<&Path>,
) -> anyhow::Result<Vec<PendingRemoteControlRecovery>> {
let path = pending_path(path);
let _guard = state_lock()
.lock()
.map_err(|_| anyhow::anyhow!("Remote Control recovery state lock poisoned"))?;
Ok(load_state(&path)?.requests)
}
pub fn enqueue_pending_remote_control_recovery(
path: Option<&Path>,
request: PendingRemoteControlRecovery,
) -> anyhow::Result<()> {
validate_request(&request)?;
let path = pending_path(path);
let _guard = state_lock()
.lock()
.map_err(|_| anyhow::anyhow!("Remote Control recovery state lock poisoned"))?;
let mut state = load_state(&path)?;
// The first observed profile/provider snapshot is authoritative. Retries for the same
// thread must not overwrite it after the user switches relay profiles.
if state
.requests
.iter()View on GitHub (pinned to b1ed92e5e4)