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 when compiling unicode-bidi inside Docker #94967

Open
metasim opened this issue Mar 15, 2022 · 4 comments
Open

Segmentation fault when compiling unicode-bidi inside Docker #94967

metasim opened this issue Mar 15, 2022 · 4 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@metasim
Copy link

metasim commented Mar 15, 2022

Not sure if this is a useful bug report or not, but I'm building an amd64 executable inside Docker on an aarch64 host (Apple Silicon). rustc aborts with a SIGSEGV when compiling unicode-bidi.

I don't have an amd64 host to test on, so I don't know if this is caused by the oddity of my build environment. I can say I've successfully built project this way that don't use unicode-bidi. But I figure any crash is useful to know about. It's easy to reproduce if you have an aarch64 host.

Code

Project Setup

cargo new amd-on-arm --lib
cd amd-on-arm
cargo add unicode-bidi 
# Create `Dockerfile` below
docker build .

Build Environment

FROM --platform=linux/amd64 rust:latest AS builder

RUN rustup target add x86_64-unknown-linux-musl
RUN apt update && apt install -y musl-tools musl-dev
RUN update-ca-certificates

COPY ./ .

RUN RUST_BACKTRACE=1 cargo build --target x86_64-unknown-linux-musl --release

Meta

uname -a
Darwin MacBook-Pro.local 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64

rustc --version --verbose:

rustc 1.59.0 (9d1b2106e 2022-02-23)
binary: rustc
commit-hash: 9d1b2106e23b1abd32fce1f17267604a5102f57a
commit-date: 2022-02-23
host: x86_64-unknown-linux-gnu
release: 1.59.0
LLVM version: 13.0.0

Error output

Backtrace

[6/6] RUN cargo build --target x86_64-unknown-linux-musl --release:
#10 4.244     Updating crates.io index
#10 98.87  Downloading crates ...
#10 99.94   Downloaded unicode-bidi v0.3.7
#10 100.5    Compiling unicode-bidi v0.3.7
#10 102.8    Compiling amd-on-arm v0.1.0 (/)
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-028c2c06c3edd7fd.so(+0x51c173)[0x40021be173]
#10 104.2 /lib/x86_64-linux-gnu/libpthread.so.0(+0x14140)[0x4005bf5140]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(_ZNK4llvm13AttributeList12addAttributeERNS_11LLVMContextEjNS_9Attribute8AttrKindE+0x954)[0x400864f634]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(+0x38feec9)[0x40096d3ec9]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(+0x24e7931)[0x40082bc931]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(+0x24e4d76)[0x40082b9d76]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(_ZN4llvm26PostOrderFunctionAttrsPass3runERNS_13LazyCallGraph3SCCERNS_15AnalysisManagerIS2_JRS1_EEES5_RNS_17CGSCCUpdateResultE+0x590)[0x40082b89d0]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(+0x24e342d)[0x40082b842d]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(_ZN4llvm11PassManagerINS_13LazyCallGraph3SCCENS_15AnalysisManagerIS2_JRS1_EEEJS4_RNS_17CGSCCUpdateResultEEE3runERS2_RS5_S4_S7_+0x3c6)[0x40089a39a6]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(+0x2bce5cd)[0x40089a35cd]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(_ZN4llvm21DevirtSCCRepeatedPass3runERNS_13LazyCallGraph3SCCERNS_15AnalysisManagerIS2_JRS1_EEES5_RNS_17CGSCCUpdateResultE+0x23a)[0x4008993ada]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(+0x2bbe88d)[0x400899388d]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(_ZN4llvm33ModuleToPostOrderCGSCCPassAdaptor3runERNS_6ModuleERNS_15AnalysisManagerIS1_JEEE+0x8af)[0x400874717f]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(+0x29718bd)[0x40087468bd]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(_ZN4llvm11PassManagerINS_6ModuleENS_15AnalysisManagerIS1_JEEEJEE3runERS1_RS3_+0x144)[0x4008c75824]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(_ZN4llvm24ModuleInlinerWrapperPass3runERNS_6ModuleERNS_15AnalysisManagerIS1_JEEE+0x13d)[0x4008c7530d]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(+0x2ea01bd)[0x4008c751bd]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.59.0-stable.so(_ZN4llvm11PassManagerINS_6ModuleENS_15AnalysisManagerIS1_JEEEJEE3runERS1_RS3_+0x144)[0x4008c75824]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-028c2c06c3edd7fd.so(+0x242c191)[0x40040ce191]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-028c2c06c3edd7fd.so(+0x2415b14)[0x40040b7b14]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-028c2c06c3edd7fd.so(+0x2416056)[0x40040b8056]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-028c2c06c3edd7fd.so(+0x23bd42e)[0x400405f42e]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-028c2c06c3edd7fd.so(+0x23f3103)[0x4004095103]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-028c2c06c3edd7fd.so(+0x2406ef7)[0x40040a8ef7]
#10 104.2 /usr/local/rustup/toolchains/1.59.0-x86_64-unknown-linux-gnu/bin/../lib/libstd-a46a068050a12a4b.so(rust_metadata_std_c2a6a440a415d498+0xa7073)[0x400590d073]
#10 104.2 /lib/x86_64-linux-gnu/libpthread.so.0(+0x8ea7)[0x4005be9ea7]
#10 104.2 /lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x4005d0bdef]
#10 104.2 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#10 104.2 error: could not compile `unicode-bidi`
#10 104.2
#10 104.2 Caused by:
#10 104.2   process didn't exit successfully: `rustc --crate-name unicode_bidi --edition=2018 /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/unicode-bidi-0.3.7/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=9385220479cd704e -C extra-filename=-9385220479cd704e --out-dir /target/x86_64-unknown-linux-musl/release/deps --target x86_64-unknown-linux-musl -L dependency=/target/x86_64-unknown-linux-musl/release/deps -L dependency=/target/release/deps --cap-lints allow` (signal: 11, SIGSEGV: invalid memory reference)

@metasim metasim added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 15, 2022
@Git-on-my-level
Copy link

Reproduced on

uname -a
Darwin Kernel Version 21.4.0: Mon Feb 21 20:35:58 PST 2022; root:xnu-8020.101.4~2/RELEASE_ARM64_T6000 arm64

Building in this container (at the time rust:latest)

https://github.com/rust-lang/docker-rust/blob/c53032d5763aa335e338d118d1bfd6c5ecc09e31/1.59.0/bullseye/Dockerfile

Running with

docker build --platform amd64 ...

@metasim
Copy link
Author

metasim commented Mar 25, 2022

@Maleware
Copy link

Hey guys,

since this issue is still open, I would like to present a solution which worked out for us.

You can leverage cargo --target , specifications can be retrieved via the list function.
From here you have to link the compiler and linker in your environment, we choose to do so with the ONBUILD option.

The example can be seen here: https://github.com/stackabletech/docker-images/blob/ubi8-rust-builder-multi-arch/ubi8-rust-builder/Dockerfile

Important for you if you use OpenSSL: You have to use the 'vendored' - feature to not have further compiling errors! E.g. in your Cargo.toml you have to have this line: openssl = { version = "0.10.41", features = ["vendored"] }

@Enselic
Copy link
Member

Enselic commented Apr 16, 2024

Triage: Can this still be reproduced? If yes, can someone please symbolize the backtrace so we can see the file and line where the crash happens? Thanks!

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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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

4 participants