Hmbown/CodeWhale · error · anyhow::Error

shell manager lock poisoned

Error message

shell manager lock poisoned

What it means

Raised when locking the shell manager Mutex: .lock() returned a PoisonError because another thread panicked while holding the manager lock. The shell manager's internal state is now considered untrustworthy; this guard converts poisoning into an explicit error at the spawn site.

Source

Thrown at crates/tui/src/tools/shell.rs:4022

    command: &str,
    heavy_permit: Option<HeavyCommandPermit>,
    working_dir: Option<String>,
    timeout_ms: Option<u64>,
    stdin_data: Option<&str>,
    tty: bool,
    policy_override: Option<ExecutionSandboxPolicy>,
    extra_env: HashMap<String, String>,
    direct_argv: bool,
    timeout_bounds_ms: (u64, u64),
) -> Result<ShellResult> {
    let timeout_ms =
        timeout_ms.map(|timeout| timeout.clamp(timeout_bounds_ms.0, timeout_bounds_ms.1));
    let spawn_timeout_ms = timeout_ms.unwrap_or(timeout_bounds_ms.1);
    let spawned = {
        let mut manager = context
            .shell_manager
            .lock()
            .map_err(|_| anyhow!("shell manager lock poisoned"))?;
        manager.clear_foreground_background_request();
        let owner = shell_job_owner_from_context(context);
        let lifecycle = shell_work_lifecycle_from_context(context);
        manager.execute_with_options_env_for_owner_and_work(
            command,
            working_dir.as_deref(),
            spawn_timeout_ms,
            true,
            stdin_data,
            tty,
            policy_override,
            extra_env,
            owner,
            context.state_namespace.clone(),
            lifecycle,
            direct_argv.then_some(context.workspace.as_path()),
            false,
            timeout_bounds_ms,

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Check logs for the earlier panic that poisoned the lock — that root cause must be fixed
  2. Restart the process to rebuild the shell manager state cleanly
  3. If the underlying panic is transient (e.g. a killed child process), the retry after restart resolves it
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at crates/tui/src/tools/shell.rs:4022 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/19d6efa3a3b3ff17. Report an issue: GitHub.