Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ghost opened this issue Aug 18, 2020 · 3 comments
Closed

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

ghost opened this issue Aug 18, 2020 · 3 comments
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-bug Category: This is a bug. O-musl Target: The musl libc T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@ghost
Copy link

ghost commented Aug 18, 2020

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.

@ghost ghost added the C-bug Category: This is a bug. label Aug 18, 2020
@jonas-schievink jonas-schievink added A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows T-libs Relevant to the library team, which will review and decide on the PR/issue. O-musl Target: The musl libc labels Aug 18, 2020
@mbrubeck
Copy link
Contributor

I believe this is caused by #31506.

@ghost
Copy link
Author

ghost commented 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.

finalclass added a commit to finalclass/sapter that referenced this issue Jun 5, 2022
@joshtriplett
Copy link
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
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-bug Category: This is a bug. O-musl Target: The musl libc T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants