openai/codex · error

{context}: {err}

Error message

{context}: {err}

What it means

A close() on an owned file descriptor failed during low-level sandbox setup. This panic in close_fd_or_panic fires with the caller-supplied context naming which fd was being closed; explicit close checks are used deliberately in these paths because swallowed close errors (EINTR/EBADF) would mask the root cause of later failures in the pipe/fd choreography around bwrap.

Solutions

  1. Use the context string in the message to identify which fd lifecycle failed
  2. Check the errno for EBADF (double close / premature close) versus EINTR
  3. Review the pipe setup path named by the context for fd-handling bugs
  4. Report as a bug with the context and errno
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at codex-rs/linux-sandbox/src/linux_run_main.rs:1492 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/3ec1e6db56e32639. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/linux-sandbox/src/linux_run_main.rs:1492

    signal_forwarders.restore();
    cleanup_signal_mask.restore();
    if libc::WIFSIGNALED(status) {
        exit_with_wait_status(status);
    }

    String::from_utf8_lossy(&stderr_bytes).into_owned()
}

/// Close an owned file descriptor and panic with context on failure.
///
/// We use explicit close() checks here (instead of ignoring return codes)
/// because this code runs in low-level sandbox setup paths where fd leaks or
/// close errors can mask the root cause of later failures.
fn close_fd_or_panic(fd: libc::c_int, context: &str) {
    let close_res = unsafe { libc::close(fd) };
    if close_res < 0 {
        let err = std::io::Error::last_os_error();
        panic!("{context}: {err}");
    }
}

fn is_proc_mount_failure(stderr: &str) -> bool {
    stderr.contains("Can't mount proc")
        && stderr.contains("/newroot/proc")
        && (stderr.contains("Invalid argument")
            || stderr.contains("Operation not permitted")
            || stderr.contains("Permission denied"))
}

struct InnerSeccompCommandArgs<'a> {
    sandbox_policy_cwd: &'a Path,
    command_cwd: Option<&'a Path>,
    permission_profile: &'a PermissionProfile,
    allow_network_for_proxy: bool,
    proxy_route_spec: Option<String>,
    command: Vec<String>,

View on GitHub (pinned to 339751715c)