Skip to content

Bug in std::thread::spawn causing "failed to spawn thread: Os { code: 22, kind: InvalidInput, message: 'Invalid argument' }" #142820

Open
@chengshuyi

Description

@chengshuyi

I tried this code:

std::thread::spawn(move || {
  .....
})

I expected to see this happen: spawn new thread

Instead, this happened:

thread 'main' panicked at /work/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:729:29:
failed to spawn thread: Os { code: 22, kind: InvalidInput, message: "Invalid argument" }

Upon further investigation using strace, it appears that the clone system call is being made with an invalid argument. Specifically, the parent_tid parameter is being passed as a pointer to tid, which seems to be incorrect.

Image

Meta

rustc --version --verbose:

binary: rustc
commit-hash: 30f168ef811aec63124eac677e14699baa9395bd
commit-date: 2025-03-05
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-needs-infoStatus: The issue lacks details necessary to triage or act on it.S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions