Repository navigation
[AVR] compiler segfaults #107261
Copy link
Copy link
Closed
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.O-AVRTarget: AVR processors (ATtiny, ATmega, etc.)Target: AVR processors (ATtiny, ATmega, etc.)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixesIssue expected to be fixed by the next major LLVM upgrade, or backported fixes
Description
On this linked repository, running cargo build --release fails with a segmentation fault:
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/librustc_driver-e0c8ab3d159f8c4e.so(+0x328ffe3)[0x7fe530e8ffe3]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7fe52d842520]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.67.0-nightly.so(+0x5736edf)[0x7fe52c136edf]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.67.0-nightly.so(+0x573570a)[0x7fe52c13570a]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.67.0-nightly.so(+0x57347c4)[0x7fe52c1347c4]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.67.0-nightly.so(+0x56d9481)[0x7fe52c0d9481]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.67.0-nightly.so(_ZN4llvm12RegAllocBase16allocatePhysRegsEv+0x14c)[0x7fe52c13020c]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.67.0-nightly.so(+0x5797f30)[0x7fe52c197f30]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.67.0-nightly.so(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0xb11)[0x7fe52c387461]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.67.0-nightly.so(_ZN4llvm13FPPassManager11runOnModuleERNS_6ModuleE+0x2f)[0x7fe52c38692f]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/libLLVM-15-rust-1.67.0-nightly.so(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x210)[0x7fe52c20b29e]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/librustc_driver-e0c8ab3d159f8c4e.so(+0x2757582)[0x7fe530357582]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/librustc_driver-e0c8ab3d159f8c4e.so(+0x2756f45)[0x7fe530356f45]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/librustc_driver-e0c8ab3d159f8c4e.so(+0x2754e97)[0x7fe530354e97]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/librustc_driver-e0c8ab3d159f8c4e.so(+0x2785f9d)[0x7fe530385f9d]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/librustc_driver-e0c8ab3d159f8c4e.so(+0x2784ecc)[0x7fe530384ecc]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/librustc_driver-e0c8ab3d159f8c4e.so(+0x2783d2e)[0x7fe530383d2e]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/librustc_driver-e0c8ab3d159f8c4e.so(+0x26898f4)[0x7fe5302898f4]
/home/cactus/sdk/rust/rustup/toolchains/nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/librustc_driver-e0c8ab3d159f8c4e.so(+0x4045b33)[0x7fe531c45b33]
/lib/x86_64-linux-gnu/libc.so.6(+0x94b43)[0x7fe52d894b43]
/lib/x86_64-linux-gnu/libc.so.6(+0x126a00)[0x7fe52d926a00]
warning: `worduino-avr` (bin "worduino-avr") generated 2 warnings (run `cargo fix --bin "worduino-avr"` to apply 2 suggestions)
error: could not compile `worduino-avr`; 2 warnings emitted
Caused by:
process didn't exit successfully: `rustc --crate-name worduino_avr src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=3 -C lto -C metadata=6d6db11dfacad857 -C extra-filename=-6d6db11dfacad857 --out-dir /home/cactus/prog/rust/avr/bugs/segfault/target/avr-atmega32u4/release/deps --target /home/cactus/prog/rust/avr/bugs/segfault/avr-atmega32u4.json -L dependency=/home/cactus/prog/rust/avr/bugs/segfault/target/avr-atmega32u4/release/deps -L dependency=/home/cactus/prog/rust/avr/bugs/segfault/target/release/deps --extern avr_config=/home/cactus/prog/rust/avr/bugs/segfault/target/avr-atmega32u4/release/deps/libavr_config-8902202b8ad51356.rlib --extern avr_std_stub=/home/cactus/prog/rust/avr/bugs/segfault/target/avr-atmega32u4/release/deps/libavr_std_stub-c3510b4296c6559e.rlib --extern 'noprelude:compiler_builtins=/home/cactus/prog/rust/avr/bugs/segfault/target/avr-atmega32u4/release/deps/libcompiler_builtins-d2b51c47ad38c941.rlib' --extern 'noprelude:core=/home/cactus/prog/rust/avr/bugs/segfault/target/avr-atmega32u4/release/deps/libcore-195cf775332e0617.rlib' --extern worduino_engine=/home/cactus/prog/rust/avr/bugs/segfault/target/avr-atmega32u4/release/deps/libworduino_engine-a6a2c489fed3cc79.rlib -Z unstable-options --emit=llvm-bc` (signal: 11, SIGSEGV: invalid memory reference)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.O-AVRTarget: AVR processors (ATtiny, ATmega, etc.)Target: AVR processors (ATtiny, ATmega, etc.)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixesIssue expected to be fixed by the next major LLVM upgrade, or backported fixes
Activity
Segfault reproducer for rust-lang/rust#107261
gergoerdi commentedon Jan 24, 2023
I tried making the reproducer as small as possible, but at some point it becomes extremely sensitive to seemingly trivial changes: for example, if I remove the unused
scorefield fromPlayer, suddenly the segfault goes away.gergoerdi commentedon Jan 25, 2023
Tried it with latest nightly, crashes just the same:
Noratrieb commentedon Jan 25, 2023
Can you try getting a backtrace where the segfault occurs by running the rustc command in a debugger?
gergoerdi commentedon Jan 25, 2023
Sure. BTW, is your question implying that you didn't manage to reproduce this with what I've provided so far? Do let me know if I'm missing some inputs that are relevant.
workingjubilee commentedon Feb 19, 2023
Just noting that this still reproduces even with avr-progmem 0.3.3, the latest fixes in rustc for AVR and
repr(C), and turning off--emit=llvm-bc.gergoerdi commentedon Feb 19, 2023
Hmm. Isn't it also a bug in itself if
--emit=llvm-bcchanges the behaviour at all?workingjubilee commentedon Feb 19, 2023
Oh, probably.
That's why I noted that it is not at fault!
Patryk27 commentedon Jun 3, 2023
fwiw, on the newest llvm-project (with debug assertions enabled), this itself:
... fails with:
Curiously, it works with 16-bit+ types; I'll see if there's anything I can do.
Edit: minimized:
Patryk27 commentedon Jun 3, 2023
Okie, patch submitted:
https://reviews.llvm.org/D152063
With that patch, compiling your application, @gergoerdi, seems to pass; I'll let know once the patch is merged and applied to rustc 🙂
Patryk27 commentedon Jul 30, 2023
Status: fixed on LLVM's side - will be solved when LLVM's version is bumped here (apparently soon ™️ ).
Patryk27 commentedon Aug 10, 2023
fwiw, this got fixed with #114048 🙂