-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Getting a Illegal instruction segfault on arm (Raspberry Pi 1) #50583
Comments
@weiznich could you verify if this ever worked on previous versions of the compiler? |
Could you collect a stacktrace? Something like this should work:
|
(I've just run the test program in gdb)
The oldest version that compiles the test snipped is rust 1.21. (Due to some features in crossbeam). It is already broken there. Compiling the same code using the
Using the
Using the |
Some raspi distros use the soft-float ABI, apparently, which could explain the gnueabihf issue. Not sure about the second issue, maybe a glibc versioning issue? Can you try compiling on the raspi? |
According to that link Arch Linux (the distro running on the Pi) supports the *hf target since 2012. Also a program without a tokio reactor works just fine. I assume this won't be the case if I've chosen the wrong target?
I will try that later. |
Building the code above on a pi using the |
Looks like the illegal instruction is in musl, where did you get musl from, maybe it's build for Armv7? Can you print the actual instruction in gdb that causes the problem? |
All targets where installed via rustup. For building against musl I used this docker file as base (I've used the
|
That's a VFPv3 instruction (raspi 1 has VFPv2), so it looks like musl has been compiled with the wrong flags. |
So I've tried to rebuild the whole musl toolchain from scratch using the same flags as the gcc installed on the raspberry pi, but I'm getting the same Illegal Instruction error as before. gcc on pi:
(musl)gcc in docker container
I'm not sure if I missed something but I thing I set all relevant flags to be the same ( |
Did you also recompile musl libc with that compiler? |
I think so. The docker file uses this to build the musl cross compiler. I've build everything from scratch. |
Wow this is a real cross-compile hell. Rustc might be using a different Maybe rustc/gcc is finding libc in the wrong place? We can find out by looking at the output of
In the |
FWIW, I'm experiencing a similar issue with tokio. Tried both
|
So I've dug into this a bit further. If I'm not misreading the output of (I've attach the full log, so somebody else could verify my conclusions. The relevant part seems to be around line 700) If someone has further ideas to try I'm happy to continue debugging this 😉 |
Aha, of course libc is shipped with the compiler, I just didn't know if the libc.rlib actually contained libc.a or not. I suppose for musl it would have to. This looks like its a bug in rustc or libc or cc. The |
I checked, and neither However, from what I've seen no ARMv6 processor supports VFP3 instructions, so they should never get emitted by default. The prinf_core implementation doesn't use any assembly code from what I can tell, so somehow the C is emittin VFP3 instructions. Maybe the compiler could be convinced to produce them if the Edit: it seems that instruction requires vfp3 only for immediate arguments. Maybe there's a bug in GCC where it doesn't know that information? |
Is there anything that I can to help fixing this? |
I managed to build musl without the offending instruction using this configure invocation:
So you'll want to figure out a way to get these gcc flags ( |
I've seen this with pretty much the same symptoms as @weiznich. A workaround appears to be to src/liblibc/ci/docker/arm-unknown-linux-musleabihf/Dockerfile, adding -mfpu=vfp to the CFLAGS:
I've built musl libc.a both with and without -mfpu=vfp, and without the -mfpu flag I get a binary with the illegal variant of vmov.f64, and with the flag I don't get it. This actually looks like a GCC bug to me - as @parched says above, it looks like VFPv3 just isn't supported on ARMv6 - this ARM doc backs that statement up. If you run:
then you get:
But if you run:
you get:
I also get the wrong answer if I put just -mcpu=arm1176jzf-s, so it's the -mfpu=vfp to force VFPv2 which is doing the trick. |
fix rust-lang/rust issue rust-lang#50583 Rationale for the fix is in rust-lang#50583. I've verified that before the fix /musl-armhf/lib/libc.a is riddled with the illegal variant of vmov.f64 and after the fix the version built doesn't contain any of these illegal instructions. I originally thought that the arm-linux-gnueabi version also needed fixing - to add a -mfloat-abi-soft but that's unnecessary as it's compiled with the gnueabi (not hf) compiler (I've some a quick check that the libc.a produced doesn't include VFP instructions). r? @alexcrichton
fix rust-lang/rust issue rust-lang#50583 Rationale for the fix is in rust-lang#50583. I've verified that before the fix /musl-armhf/lib/libc.a is riddled with the illegal variant of vmov.f64 and after the fix the version built doesn't contain any of these illegal instructions. I originally thought that the arm-linux-gnueabi version also needed fixing - to add a -mfloat-abi-soft but that's unnecessary as it's compiled with the gnueabi (not hf) compiler (I've some a quick check that the libc.a produced doesn't include VFP instructions). r? @alexcrichton
fix rust-lang/rust issue rust-lang#50583 Rationale for the fix is in rust-lang#50583. I've verified that before the fix /musl-armhf/lib/libc.a is riddled with the illegal variant of vmov.f64 and after the fix the version built doesn't contain any of these illegal instructions. I originally thought that the arm-linux-gnueabi version also needed fixing - to add a -mfloat-abi-soft but that's unnecessary as it's compiled with the gnueabi (not hf) compiler (I've some a quick check that the libc.a produced doesn't include VFP instructions). r? @alexcrichton
fix rust-lang/rust issue rust-lang#50583 Rationale for the fix is in rust-lang#50583. I've verified that before the fix /musl-armhf/lib/libc.a is riddled with the illegal variant of vmov.f64 and after the fix the version built doesn't contain any of these illegal instructions. I originally thought that the arm-linux-gnueabi version also needed fixing - to add a -mfloat-abi-soft but that's unnecessary as it's compiled with the gnueabi (not hf) compiler (I've some a quick check that the libc.a produced doesn't include VFP instructions). r? @alexcrichton
fix rust-lang/rust issue rust-lang#50583 Rationale for the fix is in rust-lang#50583. I've verified that before the fix /musl-armhf/lib/libc.a is riddled with the illegal variant of vmov.f64 and after the fix the version built doesn't contain any of these illegal instructions. I originally thought that the arm-linux-gnueabi version also needed fixing - to add a -mfloat-abi-soft but that's unnecessary as it's compiled with the gnueabi (not hf) compiler (I've some a quick check that the libc.a produced doesn't include VFP instructions). r? @alexcrichton
fix rust-lang/rust issue rust-lang#50583 Rationale for the fix is in rust-lang#50583. I've verified that before the fix /musl-armhf/lib/libc.a is riddled with the illegal variant of vmov.f64 and after the fix the version built doesn't contain any of these illegal instructions. I originally thought that the arm-linux-gnueabi version also needed fixing - to add a -mfloat-abi-soft but that's unnecessary as it's compiled with the gnueabi (not hf) compiler (I've some a quick check that the libc.a produced doesn't include VFP instructions). r? @alexcrichton
fix rust-lang/rust issue rust-lang#50583 Rationale for the fix is in rust-lang#50583. I've verified that before the fix /musl-armhf/lib/libc.a is riddled with the illegal variant of vmov.f64 and after the fix the version built doesn't contain any of these illegal instructions. I originally thought that the arm-linux-gnueabi version also needed fixing - to add a -mfloat-abi-soft but that's unnecessary as it's compiled with the gnueabi (not hf) compiler (I've some a quick check that the libc.a produced doesn't include VFP instructions). r? @alexcrichton
fix rust-lang/rust issue rust-lang#50583 Rationale for the fix is in rust-lang#50583. I've verified that before the fix /musl-armhf/lib/libc.a is riddled with the illegal variant of vmov.f64 and after the fix the version built doesn't contain any of these illegal instructions. I originally thought that the arm-linux-gnueabi version also needed fixing - to add a -mfloat-abi-soft but that's unnecessary as it's compiled with the gnueabi (not hf) compiler (I've some a quick check that the libc.a produced doesn't include VFP instructions). r? @alexcrichton
Rollup of 14 pull requests Successful merges: - #56718 (Use libbacktrace pretty-printing) - #56725 (fix rust-lang/rust issue #50583) - #56731 (Add missing urls in ffi module docs) - #56738 (Fix private_no_mangle_fns message grammar) - #56746 (Add test of current behavior (infer free region within closure body)) - #56747 (target: remove Box returned by get_targets) - #56751 (Allow ptr::hash to accept fat pointers) - #56755 (Account for `impl Trait` when suggesting lifetime) - #56758 (Add short emoji status to toolstate updates) - #56760 (Deduplicate unsatisfied trait bounds) - #56769 (Add x86_64-unknown-uefi target) - #56792 (Bootstrap: Add testsuite for compiletest tool) - #56808 (Fixes broken links) - #56809 (Fix docs path to PermissionsExt) Failed merges: r? @ghost
#56725 was merged, is this still an issue? |
The fix isn't in 1.31.1. I'm hoping it'll be in 1.32. |
Tested OK on Rust 1.33 on my Rasberry Pi 1 on Alpine distribution (musl armhf) with cross-compilation. |
Agree, this is fixed as of Rust 1.33 |
Originally reported as tokio-rs/tokio-core#324
I'm trying to run some future related code on an old raspberry pi 1. After cross compiling a binary construction a reactor and spawning a future on it the program segfaults with an illegal hardware instruction error.
Programs without a reactor are running fine.
Example code:
Versions:
rustc 1.25.0 (84203cac6 2018-03-25)
,rustc 1.27.0-nightly (79252ff4e 2018-04-29)
The text was updated successfully, but these errors were encountered: