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

i686-musl + catch_unwind = fatal runtime error: failed to initiate panic, error 5 #35599

Closed
japaric opened this issue Aug 11, 2016 · 10 comments
Closed

Comments

@japaric
Copy link
Member

japaric commented Aug 11, 2016

STR

use std::panic;

fn main() {
    let _ = panic::catch_unwind(|| panic!());
}
$ RUST_BACKTRACE=1 cargo run --target i686-unknown-linux-musl
    Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target/i686-unknown-linux-musl/debug/foo`
thread 'main' panicked at 'explicit panic', src/main.rs:4
stack backtrace:
fatal runtime error: failed to initiate panic, error 5
error: Process didn't exit successfully: `target/i686-unknown-linux-musl/debug/foo` (signal: 6, SIGABRT: process abort signal)

Meta

$ rustc -V
rustc 1.12.0-nightly (0ef24eed2 2016-08-10)

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04 LTS
Release:        16.04
Codename:       xenial

cc @alexcrichton

@alexcrichton
Copy link
Member

cc @vadimcn, maybe related to the changes in the personality?

@vadimcn
Copy link
Contributor

vadimcn commented Aug 11, 2016

Sure it's possible :)
@japaric: Can I assume that this worked before? Say, on nightly-2016-06-22?

@japaric
Copy link
Member Author

japaric commented Aug 11, 2016

Not sure, I haven't really used catch_unwind with this target before, but the snippet also fails with beta (rustc 1.11.0-beta.3 (052e32bd9 2016-08-08)) and with an older nightly (rustc 1.11.0-nightly (6dcc2c1de 2016-06-22)).

@alexcrichton
Copy link
Member

Oh if it never worked then I wonder if libunwind that we're using is just busted?

@vadimcn
Copy link
Contributor

vadimcn commented Aug 11, 2016

I would place my bet on unwind tables not being registered properly. How hard is it to set up a musl build?

@alexcrichton
Copy link
Member

For me it was just:

$ rustup target add i686-unknown-linux-musl
$ rustc foo.rs --target i686-unknown-linux-musl
$ ./foo

@vadimcn
Copy link
Contributor

vadimcn commented Aug 12, 2016

Okay, I've managed to repro this.
Looks like only i686-unknown-linux-musl is broken, x86_64-unknown-linux-musl works fine.

@alexcrichton
Copy link
Member

Ok got a chance to dig a bit more into this. Some things I've learned:

  • We compile LLVM's libunwind for musl
  • We do so with the host g++ binary. So technically we're compiling against glibc and then linking it with musl. We do this for x86_64 and it works, though, so while this is a problem I'm not sure that it's causing this problem.
  • The unwinder is finding all unwind data (using dl_iterate_phdr on Linux).
  • The unwinder successfully unwinds one frame
  • One frame aftewards the instruction pointer goes off into the weeds
  • At this point the unwinder gives up because it can't unwind.

So basically it looks like everything is working except the literal unwind step is either reading bad or wrong values. I haven't been able to get much further yet.

@alexcrichton
Copy link
Member

Found the problem!

The LLVM port of libunwind has historically understood that the dwarf register numbers for ebp and esp were 4 and 5, respectively. Recent changes, however (llvm-mirror/libunwind@85e3961 and llvm-mirror/libunwind@99e90f4) have noticed that there's some conflating of values going on here. More info in https://reviews.llvm.org/D22508 as well, but the tl;dr; is these values need to be swapped and then everything works.

@alexcrichton
Copy link
Member

alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 20, 2017
travis: Add i586 linux and i686 musl

This commit expands the existing x86_64-musl entry in the Travis matrix to also
build/test i586-unknown-linux-gnu and i686-unknown-linux-musl.

cc rust-lang#38531
Closes rust-lang#35599
Closes rust-lang#39053
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants