Skip to content

std::process::Command::spawn cause panic on Windows 10 21H2 19044.2846 #132318

Open
@Aobanana-chan

Description

@Aobanana-chan

I tried this code:

#[test]
fn test2() {
    std::process::Command::new("adb")
    .args(["devices"])
    .stdout(Stdio::piped())
    .stderr(Stdio::piped())
    .spawn()
    .unwrap();
}

Only panics when using use std::process::Command; in Test Debug mode, but not in other cases.
And only panic on Windows 10 21H2 19044.2846.

Here is an issue discussing this problem, and it includes two videos of about ten seconds to demonstrate the situation.
tokio-rs/tokio#6934

Meta

rustc --version --verbose:

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-pc-windows-msvc
release: 1.82.0
LLVM version: 19.1.1
Backtrace


test test2 ... FAILED

successes:

successes:

failures:

---- test2 stdout ----
thread 'test2' panicked at src/main.rs:80:6:
called `Result::unwrap()` on an `Err` value: Os { code: 6, kind: Uncategorized, message: "鍙ユ焺鏃犳晥銆? }
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:662
   1: core::panicking::panic_fmt
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\panicking.rs:74
   2: core::result::unwrap_failed
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\result.rs:1677
   3: enum2$<core::result::Result<std::process::Child,std::io::error::Error> >::unwrap
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library\core\src\result.rs:1102
   4: static_lib::test2
             at .\src\main.rs:77
   5: static_lib::test2::closure$0
             at .\src\main.rs:76
   6: core::ops::function::FnOnce::call_once<static_lib::test2::closure_env$0,tuple$<> >
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library\core\src\ops\function.rs:250
   7: core::ops::function::FnOnce::call_once
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\ops\function.rs:250
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
2

failures:
    test2

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.07s

I deciphered the garbled message, and it seems to mean "The handle is invalid."

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-windows-msvcToolchain: MSVC, Operating system: WindowsS-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions