
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.