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

Segmentation fault using Apple Silicon & Docker #182

Open
beck opened this issue Jul 2, 2022 · 5 comments
Open

Segmentation fault using Apple Silicon & Docker #182

beck opened this issue Jul 2, 2022 · 5 comments

Comments

@beck
Copy link

beck commented Jul 2, 2022

When compiling typenum I get:

qemu: uncaught target signal 11 (Segmentation fault) - core dumped
error: could not compile `typenum`
The full output
$ ~/src/typenum (main) docker run --rm \
>     -v "$(pwd):/typenum" \
>     -w '/typenum' \
>     -it \
>     --platform linux/amd64 \
>     rust:1.62-bullseye \
>     cargo build --release
    Updating crates.io index
   Compiling typenum v1.15.0 (/typenum)
/usr/local/rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-a7bf53640eed303a.so(+0x4e58d3)[0x40021868d3]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x14140)[0x4005fbc140]
/usr/local/rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/bin/rustc(+0x488a7)[0x40000488a7]
/usr/local/rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/bin/rustc(+0x9841)[0x4000009841]
/usr/local/rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-14-rust-1.62.0-stable.so(_ZN4llvm9MCContext5resetEv+0x55c)[0x400934ff9c]
/usr/local/rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-14-rust-1.62.0-stable.so(_ZN4llvm28MachineModuleInfoWrapperPass14doFinalizationERNS_6ModuleE+0x35)[0x400934fa05]
/usr/local/rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-14-rust-1.62.0-stable.so(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0xb0)[0x40094383d0]
/usr/local/rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-a7bf53640eed303a.so(+0x26321c5)[0x40042d31c5]
/usr/local/rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-a7bf53640eed303a.so(+0x262b307)[0x40042cc307]
/usr/local/rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-a7bf53640eed303a.so(+0x262e616)[0x40042cf616]
/usr/local/rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-a7bf53640eed303a.so(+0x2629568)[0x40042ca568]
/usr/local/rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-a7bf53640eed303a.so(+0x2623433)[0x40042c4433]
/usr/local/rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-a7bf53640eed303a.so(+0x25f2b2f)[0x4004293b2f]
/usr/local/rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-a7bf53640eed303a.so(+0x26153e3)[0x40042b63e3]
/usr/local/rustup/toolchains/1.62.0-x86_64-unknown-linux-gnu/bin/../lib/libstd-7ca39ac42651c3df.so(rust_metadata_std_62a6aef941a414a5+0xab3f3)[0x4005cc93f3]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x8ea7)[0x4005fb0ea7]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x40060d2def]
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
error: could not compile `typenum`

Caused by:
  process didn't exit successfully: `rustc --crate-name build_script_main --edition=2018 build/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off -C metadata=7c91a94b9b260f4b -C extra-filename=-7c91a94b9b260f4b --out-dir /typenum/target/release/build/typenum-7c91a94b9b260f4b -L dependency=/typenum/target/release/deps` (signal: 11, SIGSEGV: invalid memory reference)

Duplication

Using a mac with Apple Silicon (this one has an M1), cd into a new checkout of typenum (currently at 1.15.0) and run:

docker run --rm \
    -v "$(pwd):/typenum" \
    -w '/typenum' \
    -it \
    --platform linux/amd64 \
    rust:1.62-bullseye \
    cargo build --release

Note that --platform linux/amd64 is important otherwise when run on the target env will get error:

cannot execute binary file: Exec format error

Why build it like this?

because the project is deployed to a Debian environment and I am unable to build the project on the server.

I've verified building this way works when using an Intel Mac.

I'm not sure how to debug this, help / thoughts?

@dibericky
Copy link

Is there any update about this? Is this crate still maintained?

@novacrazy
Copy link
Contributor

This is not an error with typenum. You should report it to the Rust compiler team instead. It may even be a bug in QEMU.

@beck
Copy link
Author

beck commented Aug 10, 2022

@novacrazy do you have any insight as to why the issue only happens with typenum? I've not been able to reproduce with other packages. Building that extra context (or finding a minimal reproducible example) might make sense before taking it to the compiler team.

@novacrazy
Copy link
Contributor

No idea, nor am I able to test it. The segfault appears inside the compiler, though, possibly libc. It would be best to just open the issue on Rust’s repo.

@burdges
Copy link

burdges commented Aug 10, 2022

I know some projects are waiting on more from #![feature(generic_const_exprs)] but.. If possible you should really switch from typenum to const generics of course.

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

4 participants