thread panic handling broken on x32
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
use std::thread;
fn main() {
let thread = thread::spawn(move || -> () {
panic!();
});
println!("{:?}",thread.join());
}
When building the above program for x86_64-unknown-linux-gnu and running it I get
thread '<unnamed>' panicked at src/main.rs:4:9:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Err(Any { .. })
However when building for x86_64-unknown-linux-gnux32 and running it I get.
thread '<unnamed>' panicked at src/main.rs:4:9:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: Rust cannot catch foreign exceptions
Aborted
Meta
I have tested building natively with the compiler from Debian and cross building with a nightly compiler from rustup (since rust upstream don't provide a native compiler on x32).
rustc --version --verbose: (debian compiler)
rustc 1.70.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnux32
release: 1.70.0
LLVM version: 16.0.6
rustc --version --verbose: (rustup compiler)
rustc 1.76.0-nightly (2c1b65ee1 2023-11-11)
binary: rustc
commit-hash: 2c1b65ee1431f8d3fe2142e821eb13c623bbf8a0
commit-date: 2023-11-11
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.4
Note that when building with the rustup compiler I had to manually specify the linker. using the following in .cargo/config.toml
[target.x86_64-unknown-linux-gnux32]
linker = "x86_64-linux-gnux32-gcc
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the minimal thread::spawn and join example for x86_64-unknown-linux-gnux32, comparing it with x86_64-unknown-linux-gnu and checking the target linker configuration in .cargo/config.toml. Trace the Rust thread panic-handling entry points involved in the differing behavior; done means the x32 program returns the joined panic as Err instead of aborting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100