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.

Activity

ghost added
C-bugCategory: This is a bug.
on Aug 18, 2020
added
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows
T-libsRelevant to the library team, which will review and decide on the PR/issue.
O-muslTarget: The musl libc
on Aug 18, 2020
mbrubeck

mbrubeck commented on Dec 10, 2020

@mbrubeck
Contributor

I believe this is caused by #31506.

ghost

ghost commented on Dec 10, 2020

@ghost

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.

joshtriplett

joshtriplett commented on Jul 12, 2023

@joshtriplett
Member

Still segfaults in current Rust. I think we can close this in favor of the underlying issue #31506.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @mbrubeck@joshtriplett@jonas-schievink

        Issue actions

          recursions segfault on x86_64-unknown-linux-musl as target or host · Issue #75667 · rust-lang/rust