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

SIGSEGV in LLVM 13 #93372

Closed
Jake-Shadle opened this issue Jan 27, 2022 · 6 comments
Closed

SIGSEGV in LLVM 13 #93372

Jake-Shadle opened this issue Jan 27, 2022 · 6 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Jake-Shadle
Copy link

Jake-Shadle commented Jan 27, 2022

Code

Unfortunately I don't have a minimal repro for this issue since this was a regression between rust versions reported by a user that I am just now getting around to filing, and the callstack is deep in LLVM so I have no hints as to the Rust code that might be triggering it.

The code in question is https://github.com/EmbarkStudios/texture-synthesis, the original issue reported by users is EmbarkStudios/texture-synthesis#164.

This segfault only occurs with cargo build --release, debug builds are not affected.

Meta

All stable releases from 1.56.0 to 1.58.1 result in the same crash
rustc --version --verbose:

binary: rustc
commit-hash: 59eed8a2aac0230a8b53e89d4e99d55912ba6b35
commit-date: 2021-11-01
host: x86_64-unknown-linux-gnu
release: 1.56.1
LLVM version: 13.0.0

rustc 1.58.1 (db9d1b20b 2022-01-20)
binary: rustc
commit-hash: db9d1b20bba1968c1ec1fc49616d4742c1725b4b
commit-date: 2022-01-20
host: x86_64-unknown-linux-gnu
release: 1.58.1
LLVM version: 13.0.0

Rust 1.55.0 does not result in the crash

rustc 1.55.0 (c8dfcfe04 2021-09-06)
binary: rustc
commit-hash: c8dfcfe046a7680554bf4eb612bad840e7631c4b
commit-date: 2021-09-06
host: x86_64-unknown-linux-gnu
release: 1.55.0
LLVM version: 12.0.1

And neither does a recent nightly

rustc 1.60.0-nightly (8cdb3cd94 2022-01-25)
binary: rustc
commit-hash: 8cdb3cd94efece1e17cbd8f6edb1dc1a482779a0
commit-date: 2022-01-25
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 13.0.0

Error output

   Compiling texture-synthesis v0.8.1 (/home/jake/code/texture-synthesis/lib)
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f63adaab7e27a794.so(+0x4dd233)[0x7faa3d01f233]
/lib64/libc.so.6(+0x42750)[0x7faa3c5e0750]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(_ZN4llvm15ScalarEvolution22isImpliedViaOperationsENS_7CmpInst9PredicateEPKNS_4SCEVES5_S5_S5_j+0x310)[0x7faa39e10400]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(_ZN4llvm15ScalarEvolution27isImpliedCondOperandsHelperENS_7CmpInst9PredicateEPKNS_4SCEVES5_S5_S5_+0x500)[0x7faa39e0fab0]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(_ZN4llvm15ScalarEvolution13isImpliedCondENS_7CmpInst9PredicateEPKNS_4SCEVES5_PKNS_5ValueEbPKNS_11InstructionE+0x36c1)[0x7faa39e089f1]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(_ZN4llvm15ScalarEvolution27isLoopBackedgeGuardedByCondEPKNS_4LoopENS_7CmpInst9PredicateEPKNS_4SCEVES8_+0x936)[0x7faa39dfa266]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(_ZN4llvm15ScalarEvolution19isKnownViaInductionENS_7CmpInst9PredicateEPKNS_4SCEVES5_+0x270)[0x7faa39e33450]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(_ZN4llvm15ScalarEvolution31isKnownViaNonRecursiveReasoningENS_7CmpInst9PredicateEPKNS_4SCEVES5_+0x4d8)[0x7faa39dfb9b8]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(_ZN4llvm15ScalarEvolution27isImpliedCondOperandsHelperENS_7CmpInst9PredicateEPKNS_4SCEVES5_S5_S5_+0x4d8)[0x7faa39e0fa88]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(_ZN4llvm15ScalarEvolution13isImpliedCondENS_7CmpInst9PredicateEPKNS_4SCEVES5_PKNS_5ValueEbPKNS_11InstructionE+0x2e0a)[0x7faa39e0813a]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(_ZN4llvm15ScalarEvolution30isBasicBlockEntryGuardedByCondEPKNS_10BasicBlockENS_7CmpInst9PredicateEPKNS_4SCEVES8_+0x1fa)[0x7faa39df84ea]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(_ZN4llvm15ScalarEvolution19evaluatePredicateAtENS_7CmpInst9PredicateEPKNS_4SCEVES5_PKNS_11InstructionE+0x80)[0x7faa39df5e30]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(_ZN4llvm17simplifyUsersOfIVEPNS_7PHINodeEPNS_15ScalarEvolutionEPNS_13DominatorTreeEPNS_8LoopInfoEPKNS_19TargetTransformInfoERNS_15SmallVectorImplINS_14WeakTrackingVHEEERNS_12SCEVExpanderEPNS_9IVVisitorE+0x689)[0x7faa39df3b79]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(+0x24e6eaa)[0x7faa39de6eaa]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(+0x24e6106)[0x7faa39de6106]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(_ZN4llvm13LPPassManager13runOnFunctionERNS_8FunctionE+0x42d)[0x7faa3a47f36d]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(_ZN4llvm13FPPassManager13runOnFunctionERNS_8FunctionE+0x6b8)[0x7faa3a2c23c8]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(+0x2c423d9)[0x7faa3a5423d9]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(_ZN4llvm6legacy15PassManagerImpl3runERNS_6ModuleE+0x23c)[0x7faa3a63a5cc]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/../lib/libLLVM-13-rust-1.58.1-stable.so(LLVMRunPassManager+0xa)[0x7faa3aad5e5a]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f63adaab7e27a794.so(+0x2114fd5)[0x7faa3ec56fd5]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f63adaab7e27a794.so(_RNvXs1_Csdwtts9g0LY3_18rustc_codegen_llvmNtB5_18LlvmCodegenBackendNtNtNtCseZSgnbGVPHD_17rustc_codegen_ssa6traits5write19WriteBackendMethods13optimize_thin+0x67c)[0x7faa3ec6adfc]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f63adaab7e27a794.so(+0x2144742)[0x7faa3ec86742]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f63adaab7e27a794.so(+0x215cfde)[0x7faa3ec9efde]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f63adaab7e27a794.so(+0x210ce23)[0x7faa3ec4ee23]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-f63adaab7e27a794.so(+0x2141f73)[0x7faa3ec83f73]
/home/jake/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/libstd-4c74cbab78ec4891.so(rust_metadata_std_b2a2bae5f6ca25d7+0xaafc3)[0x7faa3c87cfc3]
/lib64/libc.so.6(+0x8da87)[0x7faa3c62ba87]
/lib64/libc.so.6(+0x112640)[0x7faa3c6b0640]
error: could not compile `texture-synthesis`

Caused by:
  process didn't exit successfully: `rustc --crate-name texture_synthesis --edition=2018 lib/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C metadata=87c473a03afc563c -C extra-filename=-87c473a03afc563c --out-dir /home/jake/code/texture-synthesis/target/release/deps -L dependency=/home/jake/code/texture-synthesis/target/release/deps --extern crossbeam_utils=/home/jake/code/texture-synthesis/target/release/deps/libcrossbeam_utils-905ebd46bf52a581.rmeta --extern image=/home/jake/code/texture-synthesis/target/release/deps/libimage-8bdff5c471e7e7c4.rmeta --extern num_cpus=/home/jake/code/texture-synthesis/target/release/deps/libnum_cpus-770261073a7d772a.rmeta --extern rand=/home/jake/code/texture-synthesis/target/release/deps/librand-364df1f4d518c2d0.rmeta --extern rand_pcg=/home/jake/code/texture-synthesis/target/release/deps/librand_pcg-dcc93c849e966929.rmeta --extern rstar=/home/jake/code/texture-synthesis/target/release/deps/librstar-3c02d13771cb22c5.rmeta` (signal: 11, SIGSEGV: invalid memory reference)

Since this is not a panic but a segfault the normal rust backtrace is never printed.

@Jake-Shadle Jake-Shadle 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 Jan 27, 2022
@hkratz
Copy link
Contributor

hkratz commented Jan 27, 2022

Not sure if it makes sense to investigate this if it is not reproducible in current nightly. @Jake-Shadle Can you check if it is reproducible with the current beta?

@rustbot label -I-ICE +I-crash +A-llvm

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jan 27, 2022
@Jake-Shadle
Copy link
Author

Beta has the same crash unfortunately.

rustc 1.59.0-beta.4 (436b81f58 2022-01-26)
binary: rustc
commit-hash: 436b81f58dd94dec44d33945454048a76655fbda
commit-date: 2022-01-26
host: x86_64-unknown-linux-gnu
release: 1.59.0-beta.4
LLVM version: 13.0.0

@cuviper
Copy link
Member

cuviper commented Jan 28, 2022

Nightly has the LLVM update #93081, which is nominated for beta but not yet approved or backported. However, those codegen changes are specific to AArch64, plus a little debuginfo addition for MSVC.

It could also be that some other incidental change in nightly rustc output has hidden the underlying issue.

@nikic
Copy link
Contributor

nikic commented Jan 28, 2022

Here's a reduction that crashes opt -indvars with rust's opt: https://gist.github.com/nikic/cff3b6cb9947ff324ed63c8da2ec80fa

However, it works fine with LLVM main, so this has already been fixed upstream. As this is only a crash and not a miscompile, I'm inclined to not investigate this further let this be fixed with the LLVM 14 upgrade.

@workingjubilee
Copy link
Member

I believe this has already been resolved, given that we are currently underway to LLVM 15?

@Jake-Shadle
Copy link
Author

Yes, I can compile it on stable and latest nightly without issue now so I'm going to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. 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

6 participants