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

Segfault of binary produced with relocation-model=static for x86_64-unknown-linux-musl #73661

Open
haraldh opened this issue Jun 23, 2020 · 3 comments
Labels
C-bug Category: This is a bug. O-musl Target: The musl libc P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@haraldh
Copy link
Contributor

haraldh commented Jun 23, 2020

I tried this code:

fn main() {
    println!("main = {:#x}", &main as *const _ as usize);
}

I expected to see this happen:

$ rustc -C relocation-model=static --target x86_64-unknown-linux-musl hello.rs
$ ./hello
main = 0x43b008

Instead, this happened:

$ rustc -C relocation-model=static --target x86_64-unknown-linux-musl hello.rs
$ ./hello
Segmentation fault (core dumped)

This code works, though:

fn main() {
    println!("main = {:#?}", &main as *const _);
}

Meta

Also happens with current nightly.

rustc --version --verbose:

$ rustc --version --verbose
rustc 1.44.1 (c7087fe00 2020-06-17)
binary: rustc
commit-hash: c7087fe00d2ba919df1d813c040a5d47e43b0fe7
commit-date: 2020-06-17
host: x86_64-unknown-linux-gnu
release: 1.44.1
LLVM version: 9.0
 
$ rustc +nightly --version --verbose
rustc 1.46.0-nightly (6bb3dbfc6 2020-06-22)
binary: rustc
commit-hash: 6bb3dbfc6c6d8992d08431f320ba296a0c2f7498
commit-date: 2020-06-22
host: x86_64-unknown-linux-gnu
release: 1.46.0-nightly
LLVM version: 10.0
@haraldh haraldh added the C-bug Category: This is a bug. label Jun 23, 2020
@haraldh
Copy link
Contributor Author

haraldh commented Jun 23, 2020

CC: @petrochenkov

@jonas-schievink jonas-schievink added I-prioritize Issue: Indicates that prioritization has been requested for this issue. O-musl Target: The musl libc T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 23, 2020
@haraldh
Copy link
Contributor Author

haraldh commented Jun 23, 2020

opt levels other than -C opt-level=0 do not segfault.

@LeSeulArtichaut LeSeulArtichaut added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jun 24, 2020
@LeSeulArtichaut
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-musl Target: The musl libc P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants