openai/codex · error · anyhow::Error

NtCreateFile returned an invalid sandbox ACL directory…

Error message

NtCreateFile returned an invalid sandbox ACL directory handle

What it means

NtCreateFile succeeded (status >= 0) but returned a null handle, so the raw NT call cannot be turned into an OwnedHandle for the sandbox ACL directory. This is an unexpected Windows invariant violation rather than a normal I/O error, and no further ACL mutation is attempted on the invalid handle.

Solutions

  1. Re-run the sandbox setup; a transient handle allocation failure may clear
  2. Check for kernel handle-table exhaustion (too many open handles on the system) and close leaking processes
  3. Ensure the setup binary runs elevated so handle rights (WRITE_DAC on the directory) can be granted
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win/no_reparse_dir.rs:143 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/dbbe8ba3fec37472. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win/no_reparse_dir.rs:143

            FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
            FILE_OPEN_IF,
            FILE_DIRECTORY_FILE,
            ptr::null(),
            /*ea_length*/ 0,
        )
    };
    if status < 0 {
        if status == STATUS_REPARSE_POINT_ENCOUNTERED {
            bail!(
                "sandbox ACL path contains a reparse point: {}",
                path.display()
            );
        }
        let error = unsafe { RtlNtStatusToDosError(status) };
        return Err(std::io::Error::from_raw_os_error(error as i32))
            .with_context(|| format!("open sandbox ACL directory {}", path.display()));
    }
    ensure!(
        handle != 0 && handle != INVALID_HANDLE_VALUE,
        "NtCreateFile returned an invalid sandbox ACL directory handle"
    );
    Ok(unsafe { OwnedHandle::from_raw_handle(handle as *mut c_void) })
}

#[cfg(test)]
#[path = "no_reparse_dir_tests.rs"]
mod tests;

View on GitHub (pinned to 339751715c)