Skip to content

Commit 5cac3f8

Browse files
Fix Windows pseudoconsole attribute handling for sandboxed PTY sessions (#20042)
## Summary Fix the Windows sandbox PTY spawn path to pass the pseudoconsole handle value directly into `UpdateProcThreadAttribute`. ## Why Sandboxed `unified_exec` PTY sessions on Windows were failing during child process startup with `0xc0000142` (`STATUS_DLL_INIT_FAILED`). In practice this showed up as PowerShell DLL init popups when the sandboxed background-terminal path tried to launch an interactive shell. The root cause was that we were passing a pointer to a local `isize` variable instead of the pseudoconsole handle value in the form Windows expects for `PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE`. ## Validation - `cargo build -p codex-windows-sandbox --bins` - Reproduced the real sandboxed `codex exec` flow with `windows.sandbox_private_desktop=true` - Verified a `tty=true` interactive session launched through the normal PowerShell wrapper, printed `READY`, accepted follow-up stdin, and exited cleanly - Confirmed no new `0xc0000142` / `Application Popup` events appeared after the successful repro
1 parent d92c909 commit 5cac3f8

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

codex-rs/windows-sandbox-rs/src/proc_thread_attr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::ffi::c_void;
12
use std::io;
23
use windows_sys::Win32::Foundation::GetLastError;
34
use windows_sys::Win32::Foundation::HANDLE;
@@ -45,14 +46,13 @@ impl ProcThreadAttributeList {
4546

4647
pub fn set_pseudoconsole(&mut self, hpc: isize) -> io::Result<()> {
4748
let list = self.as_mut_ptr();
48-
let mut hpc_value = hpc;
4949
let ok = unsafe {
5050
UpdateProcThreadAttribute(
5151
list,
5252
0,
5353
PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE,
54-
(&mut hpc_value as *mut isize).cast(),
55-
std::mem::size_of::<isize>(),
54+
hpc as *mut c_void,
55+
std::mem::size_of::<HANDLE>(),
5656
std::ptr::null_mut(),
5757
std::ptr::null_mut(),
5858
)

0 commit comments

Comments
 (0)