Skip to content

recursions segfault on x86_64-unknown-linux-musl as target or host #75667

Closed
@ghost

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-bugCategory: This is a bug.O-muslTarget: The musl libcT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions