Raspberry Pi Zero Rust: qemu: uncaught target signal 11 (Segmentation fault)

Hi,

I’m starting to work on Rust using a Raspberry Pi Zero. For simple applications not using external crates builds were running fine, but on including external crates cargo segfaults in qemu. I’ve verified that this runs on the host hardware fine, it only fails in the docker run.

push run:

[Build]    Step 7 : RUN cargo build
[Build]     ---> Running in e106b0574d1f
[Build]        Updating registry `https://github.com/rust-lang/crates.io-index`
[Info]     Still working...
[Build]     Downloading blinkt v0.1.2
[Build]     Downloading quick-error v1.2.0
[Build]     Downloading rppal v0.1.3
[Build]     Downloading enum_primitive v0.1.1
[Build]     Downloading num v0.1.37
[Build]     Downloading libc v0.2.23
[Build]     Downloading num-traits v0.1.37
[Build]     Downloading num-iter v0.1.33
[Build]     Downloading num-integer v0.1.34
[Build]       Compiling libc v0.2.23
[Build]       Compiling num-traits v0.1.37qemu: uncaught target signal 11 (Segmentation fault) - core dumped
[Build]    Segmentation fault (core dumped)
[Build]    Removing intermediate container e106b0574d1f
[Error]    Build failed: The command '/bin/sh -c cargo build' returned a non-zero code: 139

native run:

Updating registry `https://github.com/rust-lang/crates.io-index`
Downloading blinkt v0.1.2                    
Downloading quick-error v1.2.0               
Downloading rppal v0.1.3                     
Downloading enum_primitive v0.1.1            
Downloading num v0.1.37                      
Downloading libc v0.2.23                     
Downloading num-traits v0.1.37               
Downloading num-integer v0.1.34              
Downloading num-iter v0.1.33                 
  Compiling num-traits v0.1.37               
  Compiling num-integer v0.1.34              
  Compiling num-iter v0.1.33                 
  Compiling num v0.1.37                      
  Compiling quick-error v1.2.0               
  Compiling enum_primitive v0.1.1            
  Compiling libc v0.2.23                     
  Compiling rppal v0.1.3                     
  Compiling blinkt v0.1.2                    
  Compiling resin-rust-hello-world v0.1.0 (file:///usr/src/app)
     Finished dev [unoptimized + debuginfo] target(s) in 131.35 secs

Hey @tech2077 , I have also been struggling with this. I definitely seems related to compiling external crates in qemu. I hit the same error just building a rust docker container on Docker for MacOS which uses qemu under the covers to run armhf builds and containers. According to this bug report: https://bugs.launchpad.net/qemu/+bug/1357226 it might be memory related, so we will need to play around with trying to give qemu more memory. I’ll continue investigating and let you know what I find.

Are there possible workarounds at the moment other than local cross-compilation?

Hey @tech2077,

If it’s an truly issue with qemu then there won’t be a work around, as the builder requires qemu to build any arm containers.

So the only work around currently is to locally build and push the container straight to our registry as you have suggested.

Hey @tech2077 , we just added some native arm builders to our build system, so all the rust + qemu related problems should be a thing of the past. I would recommend pushing your project now and see that it works :slight_smile:

2 Likes