Skip to content

Miscompilation of std::thread::scope on x86_64 with llvm sysroot #1395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bjorn3 opened this issue Sep 21, 2023 · 3 comments · Fixed by bytecodealliance/wasmtime#7325
Closed
Labels
C-bug Category: This is a bug. O-x86_64 Target: x64 processors

Comments

@bjorn3
Copy link
Member

bjorn3 commented Sep 21, 2023

fn main() {
    std::thread::scope(|s| {
        s.spawn(|| {});
    });
}
$ ./y.sh build --sysroot llvm
$ dist/bin/rustc-clif foo.rs
$ RUST_BACKTRACE=1 ./foo
thread 'main' panicked at foo.rs:2:5:
a scoped thread panicked
stack backtrace:
   0: rust_begin_unwind
             at /rustc/65ea825f4021eaf77f1b25139969712d65b435a4/library/std/src/panicking.rs:619:5
   1: core::panicking::panic_fmt
             at /rustc/65ea825f4021eaf77f1b25139969712d65b435a4/library/core/src/panicking.rs:72:14
   2: std::thread::scoped::scope
   3: foo::main
   4: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Aborted (core dumped)
@bjorn3 bjorn3 added C-bug Category: This is a bug. O-x86_64 Target: x64 processors labels Sep 21, 2023
@bjorn3 bjorn3 changed the title Miscompilation of std::thread::scope on x86_64 with llvm sysroot Miscompilation of std::thread::scope on x86_64 with llvm sysroot Sep 21, 2023
@bjorn3
Copy link
Member Author

bjorn3 commented Sep 21, 2023

This blocks an update of the regex version we test.

@bjorn3
Copy link
Member Author

bjorn3 commented Oct 10, 2023

Somewhat reduced version:

fn main() {
    std::thread::scope(|s| {
        std::thread::Builder::new().spawn_scoped(s, || {}).expect("failed to spawn thread");
    });
}

@bjorn3
Copy link
Member Author

bjorn3 commented Oct 10, 2023

bytecodealliance/wasmtime#7210 seems to be the root cause of this. This issue doesn't show up when only using functions compiled with Cranelift as Cranelift doesn't ever take advantage of the uext and sext argument flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-x86_64 Target: x64 processors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant