
Description
I tried this code:
fn rec() {
rec();
}
fn main() {
rec();
}
I expected to see this happen: It should cause a runtime-error.
Instead, this happened: Segmentation fault
Meta
It happens with (on an alpine linux a musl-distro):
rustup run nightly-x86_64-unknown-linux-musl rustc segv.rs && ./segv
:
Segmentation fault
rustup run nightly-x86_64-unknown-linux-musl rustc --version --verbose
:
rustc 1.47.0-nightly (792c645ca 2020-08-17)
binary: rustc
commit-hash: 792c645ca7d11a8d254df307d019c5bf01445c37
commit-date: 2020-08-17
host: x86_64-unknown-linux-musl
release: 1.47.0-nightly
LLVM version: 10.0
It does not happen with (on fedora):
rustup run nightly-x86_64-unknown-linux-gnu rustc segv.rs && ./segv
:
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Aborted
rustup run nightly-x86_64-unknown-linux-gnu rustc --version --verbose
:
rustc 1.47.0-nightly (792c645ca 2020-08-17)
binary: rustc
commit-hash: 792c645ca7d11a8d254df307d019c5bf01445c37
commit-date: 2020-08-17
host: x86_64-unknown-linux-gnu
release: 1.47.0-nightly
LLVM version: 10.0
Additional
I also tested with the native rustc from alpine linux:
rustc 1.45.2
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-alpine-linux-musl
release: 1.45.2
LLVM version: 10.0
It has the same problem.
also cross-compiling on fedora has the same problem:
rustc --target nightly-x86_64-unknown-linux-musl segv.rs && ./segv
:
rustc 1.47.0-nightly (792c645ca 2020-08-17)
binary: rustc
commit-hash: 792c645ca7d11a8d254df307d019c5bf01445c37
commit-date: 2020-08-17
host: x86_64-unknown-linux-gnu
release: 1.47.0-nightly
LLVM version: 10.0
Originally I used this code:
struct Floaty {}
impl From<f64> for Floaty {
fn from(value: f64) -> Floaty {
value.into()
}
}
fn main() {
let _: Floaty = 1.0.into();
}
but realized that it is general problem.
Activity
mbrubeck commentedon Dec 10, 2020
I believe this is caused by #31506.
ghost commentedon Dec 10, 2020
Musl does things different in threading, for example the stacks for threads are much smaller. If rust just expects the same stacksize as for glibc, the guard-pages are probably misplaced (not where the tests expect them).
https://wiki.musl-libc.org/functional-differences-from-glibc.html
People on the musl-mailinglist are very helpful. I wanted to look into this, but never found the time.
fix: removed recursion rust-lang/rust#75667
joshtriplett commentedon Jul 12, 2023
Still segfaults in current Rust. I think we can close this in favor of the underlying issue #31506.