BigPizzaV3/CodexPlusPlus · error

bridge context lock poisoned

Error message

bridge context lock poisoned

What it means

watchdog_bridge_context reads the launcher's shared BridgeContext through a std::sync::Mutex. If a thread panicked while holding that mutex, the lock is poisoned and every subsequent lock() returns Err; the launcher converts that into this anyhow error instead of unwrapping. It signals that an earlier panic corrupted the shared watchdog state.

Solutions

  1. Find and fix the original panic that poisoned the mutex (check logs/panics occurring before the first 'lock poisoned' message).
  2. Use lock().unwrap_or_else(|p| p.into_inner()) to recover the guarded value if the data is still valid despite the panic.
  3. Replace std::sync::Mutex with parking_lot::Mutex (no poisoning) if poisoning is not meaningful here.
  4. Restart the launcher process as a workaround to clear the poisoned state.

Example fix

// before
self.bridge_context.lock().map_err(|_| anyhow!("bridge context lock poisoned"))?.clone()
// after
self.bridge_context.lock().unwrap_or_else(|poisoned| poisoned.into_inner()).clone()
Defensive patterns

Strategy: try-catch

Try / catch

let ctx = match launcher.watchdog_bridge_context() {
    Ok(ctx) => ctx,
    Err(e) if e.to_string().contains("lock poisoned") => { log_panic_root_cause(); return; }
    Err(e) => return Err(e),
};

Prevention

When it happens

Trigger: Any thread holding the bridge_context mutex guard panics (e.g. a bug in hook code or a downstream callee that unwraps a None/failed result), after which every watchdog tick calling watchdog_bridge_context fails with this message.

Common situations: A one-time panic in the bridge setup/hook path silently poisoning the lock, then every subsequent watchdog restart attempt reporting 'lock poisoned' repeatedly; debugging after an aborted process section.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/c2f3109b2c210492. Report an issue: GitHub.

Appendix: source

Thrown at apps/codex-plus-launcher/src/main.rs:43

    fn default() -> Self {
        Self {
            core: Arc::new(DefaultLaunchHooks::default()),
            data: Arc::new(LauncherDataService::default()),
            runtime: Arc::new(LauncherRuntimeService::new(
                9229,
                default_user_script_manager(),
            )),
            bridge_context: Arc::new(Mutex::new(None)),
            browser_monitor: Arc::new(Mutex::new(None)),
        }
    }
}

impl LauncherHooks {
    fn watchdog_bridge_context(&self) -> anyhow::Result<BridgeContext> {
        self.bridge_context
            .lock()
            .map_err(|_| anyhow::anyhow!("bridge context lock poisoned"))?
            .clone()
            .ok_or_else(|| anyhow::anyhow!("bridge context is not initialized"))
    }
}

#[tokio::main]
async fn main() -> Result<()> {
    let args = std::env::args().skip(1).collect::<Vec<_>>();
    let helper_only = args.iter().any(|arg| arg == "--helper-only");
    let options = parse_launch_options(args.iter());
    if let Err(error) = launcher_main(args, helper_only, options.clone()).await {
        let _ = codex_plus_core::diagnostic_log::append_diagnostic_log(
            "launcher.failed",
            json!({
                "message": error.to_string()
            }),
        );
        if !helper_only {

View on GitHub (pinned to b1ed92e5e4)