Skip to content

core::arch tests ICE rust in release mode (SIGSEGV) #57993

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

Closed
gnzlbg opened this issue Jan 30, 2019 · 5 comments · Fixed by rust-lang/stdarch#661
Closed

core::arch tests ICE rust in release mode (SIGSEGV) #57993

gnzlbg opened this issue Jan 30, 2019 · 5 comments · Fixed by rust-lang/stdarch#661
Labels
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. 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

@gnzlbg
Copy link
Contributor

gnzlbg commented Jan 30, 2019

To reproduce:

git clone https://github.com/rust-lang-nursery/stdsimd
cd stdsimd/crates/core_arch
cargo build --release 
cargo test --release

Here cargo test --release fails with:

error: Could not compile `core_arch`.

Caused by:
  process didn't exit successfully: `rustc --crate-name core_arch crates/core_arch/src/lib.rs 
--color always --emit=dep-info,link -C opt-level=3 -C debuginfo=1 --test 
-C metadata=e182289efaf15ad2 -C extra-filename=-e182289efaf15ad2 
--out-dir stdsimd/target/release/deps -C incremental=stdsimd/target/release/incremental 
-L dependency=stdsimd/target/release/deps 
--extern std_detect=stdsimd/target/release/deps/libstd_detect-9c6c529b12e45786.rlib 
--extern stdsimd_test=stdsimd/target/release/deps/libstdsimd_test-16ca4dda6e920c9c.rlib`

 (signal: 11, SIGSEGV: invalid memory reference)
@jonas-schievink jonas-schievink added 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. labels Jan 30, 2019
@nagisa nagisa added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. labels Jan 30, 2019
@mati865
Copy link
Contributor

mati865 commented Jan 30, 2019

It doesn't crash with nightly-2019-01-24, but does with 43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac (latest commit right now).
Here is the backtrace:

Thread 72 "rustc" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffaaeff700 (LWP 9845)]
0x00007fffeb0d6b73 in bool llvm::DenseMapBase<llvm::DenseMap<llvm::ConstantExpr*, llvm::detail::DenseSetEmpty, llvm::ConstantUniqueMap<llvm::ConstantExpr>::MapInfo, llvm::detail::DenseSetPair<llvm::ConstantExpr*> >, llvm::ConstantExpr*, llvm::detail::DenseSetEmpty, llvm::ConstantUniqueMap<llvm::ConstantExpr>::MapInfo, llvm::detail::DenseSetPair<llvm::ConstantExpr*> >::LookupBucketFor<std::pair<unsigned int, std::pair<llvm::Type*, llvm::ConstantExprKeyType> > >(std::pair<unsigned int, std::pair<llvm::Type*, llvm::ConstantExprKeyType> > const&, llvm::detail::DenseSetPair<llvm::ConstantExpr*> const*&) const ()
   from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
(gdb) bt
#0  0x00007fffeb0d6b73 in bool llvm::DenseMapBase<llvm::DenseMap<llvm::ConstantExpr*, llvm::detail::DenseSetEmpty, llvm::ConstantUniqueMap<llvm::ConstantExpr>::MapInfo, llvm::detail::DenseSetPair<llvm::ConstantExpr*> >, llvm::ConstantExpr*, llvm::detail::DenseSetEmpty, llvm::ConstantUniqueMap<llvm::ConstantExpr>::MapInfo, llvm::detail::DenseSetPair<llvm::ConstantExpr*> >::LookupBucketFor<std::pair<unsigned int, std::pair<llvm::Type*, llvm::ConstantExprKeyType> > >(std::pair<unsigned int, std::pair<llvm::Type*, llvm::ConstantExprKeyType> > const&, llvm::detail::DenseSetPair<llvm::ConstantExpr*> const*&) const ()
   from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
#1  0x00007fffeb0cc3d5 in llvm::ConstantUniqueMap<llvm::ConstantExpr>::getOrCreate(llvm::Type*, llvm::ConstantExprKeyType) ()
   from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
#2  0x00007fffeb0c9d15 in llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, llvm::Type*, bool) ()
   from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
#3  0x00007fffec0f9458 in SimplifyCastInst(unsigned int, llvm::Value*, llvm::Type*, llvm::SimplifyQuery const&, unsigned int) [clone .llvm.2514803166611426531] ()
   from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
#4  0x00007fffec0fb8ac in llvm::SimplifyInstruction(llvm::Instruction*, llvm::SimplifyQuery const&, llvm::OptimizationRemarkEmitter*) ()
   from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
#5  0x00007fffec26abaa in llvm::GetUnderlyingObject(llvm::Value*, llvm::DataLayout const&, unsigned int) ()
   from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
#6  0x00007fffec0356f6 in llvm::BasicAAResult::pointsToConstantMemory(llvm::MemoryLocation const&, bool) ()
   from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
#7  0x00007fffebe94a73 in checkFunctionMemoryAccess(llvm::Function&, bool, llvm::AAResults&, llvm::SmallSetVector<llvm::Function*, 8u> const&) [clone .llvm.6289148742381344558] ()
   from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
#8  0x00007fffebe9715b in (anonymous namespace)::PostOrderFunctionAttrsLegacyPass::runOnSCC ()
   from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
#9  0x00007fffec07c791 in (anonymous namespace)::CGPassManager::runOnModule ()
   from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
#10 0x00007fffeb180572 in llvm::legacy::PassManagerImpl::run(llvm::Module&) ()
   from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
#11 0x00007fffeb0ea6ea in LLVMRunPassManager () from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
#12 0x00007fffede4d070 in rustc_codegen_llvm::back::write::optimize ()
   from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#13 0x00007fffede1f12d in rustc_codegen_ssa::back::write::execute_work_item () from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#14 0x00007fffedd9ed09 in std::sys_common::backtrace::__rust_begin_short_backtrace () from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#15 0x00007fffeddd99c6 in std::panicking::try::do_call () from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#16 0x00007ffff78daeca in __rust_maybe_catch_panic () at src/libpanic_unwind/lib.rs:92
#17 0x00007fffedd7b3a8 in <F as alloc::boxed::FnBox<A>>::call_box () from /home/mateusz/.rustup/toolchains/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#18 0x00007ffff78d9cce in call_once<(),()> () at /rustc/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/src/liballoc/boxed.rs:744
#19 start_thread () at src/libstd/sys_common/thread.rs:14
#20 thread_start () at src/libstd/sys/unix/thread.rs:81
#21 0x00007ffff781c58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#22 0x00007ffff773b6a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Jan 30, 2019

@mati865 are you using LLVM with assertions enabled? (that is, did no assertions trigger?)

@mati865
Copy link
Contributor

mati865 commented Jan 30, 2019

It was without assertions, when assertions are enabled build exits with:

rustc: /checkout/src/llvm-project/llvm/include/llvm/IR/InstrTypes.h:1136: llvm::Value *llvm::CallBase::getArgOperand(unsigned int) const: Assertion `i < getNumArgOperands() && "Out of bounds!"' failed.
error: Could not compile `core_arch`.

Backtrace:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff7660895 in __GI_abort () at abort.c:79
#2  0x00007ffff7660769 in __assert_fail_base (fmt=0x7ffff77c7e90 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x7fffe9d8e74f <.str.77.llvm> "i < getNumArgOperands() && \"Out of bounds!\"", 
    file=0x7fffe9576793 <.str.80.llvm> "/checkout/src/llvm-project/llvm/include/llvm/IR/InstrTypes.h", line=1136, function=<optimized out>) at assert.c:92
#3  0x00007ffff766e9f6 in __GI___assert_fail (assertion=0x7fffe9d8e74f <.str.77.llvm> "i < getNumArgOperands() && \"Out of bounds!\"", 
    file=0x7fffe9576793 <.str.80.llvm> "/checkout/src/llvm-project/llvm/include/llvm/IR/InstrTypes.h", line=1136, 
    function=0x7fffe94c3524 <__PRETTY_FUNCTION__._ZNK4llvm8CallBase13getArgOperandEj.llvm.9461709957181598743> "llvm::Value *llvm::CallBase::getArgOperand(unsigned int) const") at assert.c:101
#4  0x00007fffeadc6bfc in llvm::UpgradeIntrinsicCall(llvm::CallInst*, llvm::Function*) () from /home/mateusz/.rustup/toolchains/alt/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
#5  0x00007fffeadcc01a in llvm::UpgradeCallsToIntrinsic(llvm::Function*) () from /home/mateusz/.rustup/toolchains/alt/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/../lib/libLLVM-8.so
#6  0x00007fffee0adfa9 in LLVMRustRunFunctionPassManager () from /home/mateusz/.rustup/toolchains/alt/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#7  0x00007fffee04b7a1 in rustc_codegen_llvm::back::write::optimize () from /home/mateusz/.rustup/toolchains/alt/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#8  0x00007fffee01d92d in rustc_codegen_ssa::back::write::execute_work_item () from /home/mateusz/.rustup/toolchains/alt/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#9  0x00007fffedf9d509 in std::sys_common::backtrace::__rust_begin_short_backtrace ()
   from /home/mateusz/.rustup/toolchains/alt/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#10 0x00007fffedfd81c6 in std::panicking::try::do_call () from /home/mateusz/.rustup/toolchains/alt/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#11 0x00007ffff78daeca in __rust_maybe_catch_panic () at src/libpanic_unwind/lib.rs:92
#12 0x00007fffedf79ba8 in <F as alloc::boxed::FnBox<A>>::call_box () from /home/mateusz/.rustup/toolchains/alt/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_codegen_llvm-llvm.so
#13 0x00007ffff78d9cce in call_once<(),()> () at /rustc/43b4c4a36b6c189bf0718a9d77ff1164c3fa7cac/src/liballoc/boxed.rs:744
#14 start_thread () at src/libstd/sys_common/thread.rs:14
#15 thread_start () at src/libstd/sys/unix/thread.rs:81
#16 0x00007ffff781c58e in start_thread (arg=<optimized out>) at pthread_create.c:486
#17 0x00007ffff773b6a3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

If you want to try it yourself the toolchain can be installed via rustup-toolchain-install-master. Normal builds don't have assertions but alt builds have them on.

@nikic
Copy link
Contributor

nikic commented Jan 30, 2019

Just ran the bitcode through a debug opt build, this is the failing line: https://github.com/llvm-mirror/llvm/blob/release_80/lib/IR/AutoUpgrade.cpp#L3259

@nikic
Copy link
Contributor

nikic commented Jan 30, 2019

Okay, it's failing to upgrade addcarry.u32. I believe this is a bug in stdsimd, because you're linking llvm.x86.addcarry.u32 (old intrinsic) against the signature of llvm.x86.addcarry.32 (new intrinsic). Note the difference in the u. Same applies to subborrow and 64-bit variants.

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. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. 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

Successfully merging a pull request may close this issue.

5 participants