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

Regression: "SIGFPE: erroneous arithmetic operation" while compiling Servo in release mode #46519

Closed
SimonSapin opened this issue Dec 5, 2017 · 8 comments
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. regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Milestone

Comments

@SimonSapin
Copy link
Contributor

Running RUSTFLAGS="-Z time-passes" mach build --release -p style -v, rustc 1.23.0-nightly (5041b3b 2017-11-19) succeeds, rustc 1.23.0-nightly (33374fa 2017-11-20) fails without an error message. Range: 5041b3b...33374fa. #45225 seems to be the only compiler change in that range. CC @eddyb

Full output: https://gist.github.com/anonymous/e0881601130599a2c3853f876b5efc7a

Extract that seems most relevant:

$ RUSTFLAGS="-Z time-passes" mach build --release -p style -v
cargo build -p style --manifest-path /home/simon/servo3/ports/servo/Cargo.toml --release -v
       Fresh unicode-xid v0.0.4
[]
       Fresh style_traits v0.0.1 (file:///home/simon/servo3/components/style_traits)
   Compiling style v0.0.1 (file:///home/simon/servo3/components/style)
     Running `rustc --crate-name []`
  time: 0.113; rss: 82MB	parsing
[]
    time: 0.115; rss: 1659MB	codegen passes [core-fmt-builders.volatile]
    time: 0.042; rss: 1659MB	llvm function passes [style-values-specified-font]
    time: 1.306; rss: 1660MB	llvm module passes [std-collections-hash-map.volatile]
    time: 1.213; rss: 1661MB	llvm module passes [style-properties-declaration_block]
    time: 0.514; rss: 1659MB	llvm module passes [core-result.volatile]
    time: 0.040; rss: 1662MB	llvm function passes [style-animation]
error: Could not compile `style`.

Caused by:
  process didn't exit successfully: `rustc --crate-name style []` (signal: 8, SIGFPE: erroneous arithmetic operation)

time-passes is used to get some idea of what stage of compilation is happening.

So far I have managed to run rustc with correct arguments within gdb.

My daily "build servo with rust nightly" job did not catch this because this only happens in release mode.

@kennytm kennytm 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. regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Dec 5, 2017
@Mark-Simulacrum Mark-Simulacrum added this to the 1.23 milestone Dec 5, 2017
@SimonSapin
Copy link
Contributor Author

SimonSapin commented Dec 5, 2017

After some gdb wrangling I got a stack trace:

#0  0x00007fffeff32159 in llvm::APInt::rotl(unsigned int) const ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/../lib/librustc_llvm-50edb4a75bc0fe7c.so
#1  0x00007fffeff3238b in llvm::APInt::isSplat(unsigned int) const ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/../lib/librustc_llvm-50edb4a75bc0fe7c.so
#2  0x00007fffefc9d1c7 in llvm::isBytewiseValue(llvm::Value*) ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/../lib/librustc_llvm-50edb4a75bc0fe7c.so
#3  0x00007fffef8fe7d7 in llvm::MemCpyOptPass::processStore(llvm::StoreInst*, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void>, false, false>&) ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/../lib/librustc_llvm-50edb4a75bc0fe7c.so
#4  0x00007fffef8fff2b in llvm::MemCpyOptPass::iterateOnFunction(llvm::Function&) ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/../lib/librustc_llvm-50edb4a75bc0fe7c.so
#5  0x00007fffef900239 in llvm::MemCpyOptPass::runImpl(llvm::Function&, llvm::MemoryDependenceResults*, llvm::TargetLibraryInfo*, std::function<llvm::AAResults& ()>, std::function<llvm::AssumptionCache& ()>, std::function<llvm::DominatorTree& ()>) ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/../lib/librustc_llvm-50edb4a75bc0fe7c.so
#6  0x00007fffef9003fc in (anonymous namespace)::MemCpyOptLegacyPass::runOnFunction(llvm::Function&) ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/../lib/librustc_llvm-50edb4a75bc0fe7c.so
#7  0x00007fffefdf5f4a in llvm::FPPassManager::runOnFunction(llvm::Function&) ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/../lib/librustc_llvm-50edb4a75bc0fe7c.so
#8  0x00007fffefb6c5df in (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/../lib/librustc_llvm-50edb4a75bc0fe7c.so
#9  0x00007fffefdf6950 in llvm::legacy::PassManagerImpl::run(llvm::Module&) ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/../lib/librustc_llvm-50edb4a75bc0fe7c.so
#10 0x00007fffefd8d879 in LLVMRunPassManager ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/../lib/librustc_llvm-50edb4a75bc0fe7c.so
#11 0x00007ffff5b592f5 in rustc::util::common::time ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/librustc_trans-64828bfa1a07d0dd.so
#12 0x00007ffff5b1eaba in std::sys_common::backtrace::__rust_begin_short_backtrace ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/librustc_trans-64828bfa1a07d0dd.so
#13 0x00007ffff5b23408 in std::panicking::try::do_call ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/librustc_trans-64828bfa1a07d0dd.so
#14 0x00007ffff76b3e6f in panic_unwind::__rust_maybe_catch_panic () at /checkout/src/libpanic_unwind/lib.rs:101
#15 0x00007ffff5b29d0b in <F as alloc::boxed::FnBox<A>>::call_box ()
   from /home/simon/tmp/servo-share/rust/2017-11-21/rustc-nightly-x86_64-unknown-linux-gnu/rustc/bin/../lib/../lib/librustc_trans-64828bfa1a07d0dd.so
#16 0x00007ffff76a73cc in alloc::boxed::{{impl}}::call_once<(),()> () at /checkout/src/liballoc/boxed.rs:782
#17 std::sys_common::thread::start_thread () at /checkout/src/libstd/sys_common/thread.rs:24
#18 std::sys::imp::thread::{{impl}}::new::thread_start () at /checkout/src/libstd/sys/unix/thread.rs:90
#19 0x00007ffff15e27fc in start_thread (arg=0x7fff661ff700) at pthread_create.c:465
#20 0x00007ffff7362b0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

@SimonSapin
Copy link
Contributor Author

SimonSapin commented Dec 5, 2017

disassemble in gdb:

=> 0x00007fffeff32159 <+25>:	div    %r8d
Dump of assembler code for function _ZNK4llvm5APInt4rotlEj:
   0x00007fffeff32140 <+0>:	push   %r14
   0x00007fffeff32142 <+2>:	mov    %edx,%eax
   0x00007fffeff32144 <+4>:	xor    %edx,%edx
   0x00007fffeff32146 <+6>:	push   %r13
   0x00007fffeff32148 <+8>:	push   %r12
   0x00007fffeff3214a <+10>:	push   %rbp
   0x00007fffeff3214b <+11>:	mov    %rsi,%rbp
   0x00007fffeff3214e <+14>:	push   %rbx
   0x00007fffeff3214f <+15>:	mov    %rdi,%rbx
   0x00007fffeff32152 <+18>:	sub    $0x20,%rsp
   0x00007fffeff32156 <+22>:	mov    (%rsi),%r8d
=> 0x00007fffeff32159 <+25>:	div    %r8d
   0x00007fffeff3215c <+28>:	test   %edx,%edx
   0x00007fffeff3215e <+30>:	mov    %edx,%r12d
   0x00007fffeff32161 <+33>:	jne    0x7fffeff32190 <_ZNK4llvm5APInt4rotlEj+80>
   0x00007fffeff32163 <+35>:	cmp    $0x40,%r8d
   0x00007fffeff32167 <+39>:	mov    %r8d,(%rdi)
   0x00007fffeff3216a <+42>:	movq   $0x0,0x8(%rdi)
   0x00007fffeff32172 <+50>:	ja     0x7fffeff32238 <_ZNK4llvm5APInt4rotlEj+248>
   0x00007fffeff32178 <+56>:	mov    0x8(%rsi),%rax
   0x00007fffeff3217c <+60>:	mov    %rax,0x8(%rdi)
   0x00007fffeff32180 <+64>:	add    $0x20,%rsp
   0x00007fffeff32184 <+68>:	mov    %rbx,%rax
   0x00007fffeff32187 <+71>:	pop    %rbx
   0x00007fffeff32188 <+72>:	pop    %rbp
   0x00007fffeff32189 <+73>:	pop    %r12
   0x00007fffeff3218b <+75>:	pop    %r13
   0x00007fffeff3218d <+77>:	pop    %r14
   0x00007fffeff3218f <+79>:	retq   
   0x00007fffeff32190 <+80>:	lea    0x10(%rsp),%r13
   0x00007fffeff32195 <+85>:	mov    %r8d,%edx
   0x00007fffeff32198 <+88>:	sub    %r12d,%edx
   0x00007fffeff3219b <+91>:	mov    %r13,%rdi
   0x00007fffeff3219e <+94>:	callq  0x7fffee7b3910 <_ZNK4llvm5APInt4lshrEj@plt>
   0x00007fffeff321a3 <+99>:	mov    0x0(%rbp),%eax
   0x00007fffeff321a6 <+102>:	cmp    $0x40,%eax
   0x00007fffeff321a9 <+105>:	ja     0x7fffeff322b0 <_ZNK4llvm5APInt4rotlEj+368>
   0x00007fffeff321af <+111>:	cmp    %eax,%r12d
   0x00007fffeff321b2 <+114>:	jae    0x7fffeff32250 <_ZNK4llvm5APInt4rotlEj+272>
   0x00007fffeff321b8 <+120>:	mov    0x8(%rbp),%rdx
   0x00007fffeff321bc <+124>:	mov    %r12d,%ecx
   0x00007fffeff321bf <+127>:	mov    %rsp,%rdi
   0x00007fffeff321c2 <+130>:	mov    %eax,(%rsp)
   0x00007fffeff321c5 <+133>:	mov    %rsp,%r14
   0x00007fffeff321c8 <+136>:	shl    %cl,%rdx
   0x00007fffeff321cb <+139>:	mov    %rdx,0x8(%rsp)
   0x00007fffeff321d0 <+144>:	callq  0x7fffee94cab0 <_ZN4llvm5APInt15clearUnusedBitsEv>
   0x00007fffeff321d5 <+149>:	mov    (%rsp),%eax
   0x00007fffeff321d8 <+152>:	cmp    $0x40,%eax
   0x00007fffeff321db <+155>:	jbe    0x7fffeff32273 <_ZNK4llvm5APInt4rotlEj+307>
   0x00007fffeff321e1 <+161>:	mov    %r13,%rdx
   0x00007fffeff321e4 <+164>:	mov    %r14,%rsi
   0x00007fffeff321e7 <+167>:	mov    %rbx,%rdi
   0x00007fffeff321ea <+170>:	callq  0x7fffee7c1290 <_ZNK4llvm5APInt10OrSlowCaseERKS0_@plt>
   0x00007fffeff321ef <+175>:	cmpl   $0x40,(%rsp)
   0x00007fffeff321f3 <+179>:	jbe    0x7fffeff32204 <_ZNK4llvm5APInt4rotlEj+196>
   0x00007fffeff321f5 <+181>:	mov    0x8(%rsp),%rdi
   0x00007fffeff321fa <+186>:	test   %rdi,%rdi
   0x00007fffeff321fd <+189>:	je     0x7fffeff32204 <_ZNK4llvm5APInt4rotlEj+196>
   0x00007fffeff321ff <+191>:	callq  0x7fffee7e99f0 <_ZdaPv@plt>
   0x00007fffeff32204 <+196>:	cmpl   $0x40,0x10(%rsp)
   0x00007fffeff32209 <+201>:	jbe    0x7fffeff32180 <_ZNK4llvm5APInt4rotlEj+64>
   0x00007fffeff3220f <+207>:	mov    0x18(%rsp),%rdi
   0x00007fffeff32214 <+212>:	test   %rdi,%rdi
   0x00007fffeff32217 <+215>:	je     0x7fffeff32180 <_ZNK4llvm5APInt4rotlEj+64>
   0x00007fffeff3221d <+221>:	callq  0x7fffee7e99f0 <_ZdaPv@plt>
   0x00007fffeff32222 <+226>:	add    $0x20,%rsp
   0x00007fffeff32226 <+230>:	mov    %rbx,%rax
   0x00007fffeff32229 <+233>:	pop    %rbx
   0x00007fffeff3222a <+234>:	pop    %rbp
   0x00007fffeff3222b <+235>:	pop    %r12
   0x00007fffeff3222d <+237>:	pop    %r13
   0x00007fffeff3222f <+239>:	pop    %r14
   0x00007fffeff32231 <+241>:	retq   
   0x00007fffeff32232 <+242>:	nopw   0x0(%rax,%rax,1)
   0x00007fffeff32238 <+248>:	callq  0x7fffee7d1d20 <_ZN4llvm5APInt12initSlowCaseERKS0_@plt>
   0x00007fffeff3223d <+253>:	add    $0x20,%rsp
   0x00007fffeff32241 <+257>:	mov    %rbx,%rax
   0x00007fffeff32244 <+260>:	pop    %rbx
   0x00007fffeff32245 <+261>:	pop    %rbp
   0x00007fffeff32246 <+262>:	pop    %r12
   0x00007fffeff32248 <+264>:	pop    %r13
   0x00007fffeff3224a <+266>:	pop    %r14
   0x00007fffeff3224c <+268>:	retq   
   0x00007fffeff3224d <+269>:	nopl   (%rax)
   0x00007fffeff32250 <+272>:	mov    %rsp,%rdi
   0x00007fffeff32253 <+275>:	mov    %eax,(%rsp)
   0x00007fffeff32256 <+278>:	movq   $0x0,0x8(%rsp)
   0x00007fffeff3225f <+287>:	callq  0x7fffee94cab0 <_ZN4llvm5APInt15clearUnusedBitsEv>
   0x00007fffeff32264 <+292>:	mov    (%rsp),%eax
   0x00007fffeff32267 <+295>:	mov    %rsp,%r14
   0x00007fffeff3226a <+298>:	cmp    $0x40,%eax
   0x00007fffeff3226d <+301>:	ja     0x7fffeff321e1 <_ZNK4llvm5APInt4rotlEj+161>
   0x00007fffeff32273 <+307>:	mov    0x18(%rsp),%rdx
   0x00007fffeff32278 <+312>:	or     0x8(%rsp),%rdx
   0x00007fffeff3227d <+317>:	mov    %eax,(%rbx)
   0x00007fffeff3227f <+319>:	and    $0x3f,%eax
   0x00007fffeff32282 <+322>:	mov    %rdx,0x8(%rbx)
   0x00007fffeff32286 <+326>:	je     0x7fffeff32204 <_ZNK4llvm5APInt4rotlEj+196>
   0x00007fffeff3228c <+332>:	mov    $0x40,%ecx
   0x00007fffeff32291 <+337>:	sub    %eax,%ecx
   0x00007fffeff32293 <+339>:	mov    $0xffffffffffffffff,%rax
   0x00007fffeff3229a <+346>:	shr    %cl,%rax
   0x00007fffeff3229d <+349>:	and    %rdx,%rax
   0x00007fffeff322a0 <+352>:	mov    %rax,0x8(%rbx)
   0x00007fffeff322a4 <+356>:	jmpq   0x7fffeff32204 <_ZNK4llvm5APInt4rotlEj+196>
   0x00007fffeff322a9 <+361>:	nopl   0x0(%rax)
   0x00007fffeff322b0 <+368>:	mov    %r12d,%edx
   0x00007fffeff322b3 <+371>:	mov    %rbp,%rsi
   0x00007fffeff322b6 <+374>:	mov    %rsp,%rdi
   0x00007fffeff322b9 <+377>:	mov    %rsp,%r14
   0x00007fffeff322bc <+380>:	callq  0x7fffee7b3b90 <_ZNK4llvm5APInt11shlSlowCaseEj@plt>
   0x00007fffeff322c1 <+385>:	jmpq   0x7fffeff321d5 <_ZNK4llvm5APInt4rotlEj+149>
End of assembler dump.

@SimonSapin
Copy link
Contributor Author

With a "alt" compiler downloaded from https://s3.amazonaws.com/rust-lang-ci/rustc-builds-alt/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea/rust-nightly-x86_64-unknown-linux-gnu.tar.gz, the output is:

$ cargo +alt-2017-12-04 build --release -p style --manifest-path ports/servo/Cargo.toml -v
[]
rustc: /checkout/src/llvm/include/llvm/Support/Casting.h:236: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::IntegerType; Y = llvm::Type; typename llvm::cast_retty<X, Y*>::ret_type = llvm::IntegerType*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
error: Could not compile `style`.

Caused by:
  process didn't exit successfully: `rustc --crate-name style []` (signal: 6, SIGABRT: process abort signal)

@SimonSapin
Copy link
Contributor Author

SimonSapin commented Dec 5, 2017

And gdb stack track for that:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff726ff5d in __GI_abort () at abort.c:90
#2  0x00007ffff7265f17 in __assert_fail_base (fmt=<optimized out>, 
    assertion=assertion@entry=0x7fffef3ea0e0 "isa<X>(Val) && \"cast<Ty>() argument of incompatible type!\"", 
    file=file@entry=0x7fffef547a20 "/checkout/src/llvm/include/llvm/Support/Casting.h", line=line@entry=236, 
    function=function@entry=0x7ffff0539ba0 <_ZZN4llvm4castINS_11IntegerTypeENS_4TypeEEENS_10cast_rettyIT_PT0_E8ret_typeES6_E19__PRETTY_FUNCTION__> "typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::IntegerType; Y = llvm::Type; typename llvm::cast_retty<X, Y*>::ret_type = llvm::IntegerType*]") at assert.c:92
#3  0x00007ffff7265fc2 in __GI___assert_fail (
    assertion=0x7fffef3ea0e0 "isa<X>(Val) && \"cast<Ty>() argument of incompatible type!\"", 
    file=0x7fffef547a20 "/checkout/src/llvm/include/llvm/Support/Casting.h", line=236, 
    function=0x7ffff0539ba0 <_ZZN4llvm4castINS_11IntegerTypeENS_4TypeEEENS_10cast_rettyIT_PT0_E8ret_typeES6_E19__PRETTY_FUNCTION__> "typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::IntegerType; Y = llvm::Type; typename llvm::cast_retty<X, Y*>::ret_type = llvm::IntegerType*]") at assert.c:101
#4  0x00007fffef0f5eca in LLVMConstIntOfArbitraryPrecision ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/../lib/librustc_llvm-fe79b73fb19ea62e.so
#5  0x00007ffff5a400c7 in rustc_trans::mir::place::PlaceRef::trans_set_discr ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc_trans-84cc35c4fa80a856.so
#6  0x00007ffff5a51546 in rustc_trans::mir::rvalue::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_rvalue ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc_trans-84cc35c4fa80a856.so

[]
#7  0x00007ffff5a49a69 in rustc_trans::mir::trans_mir ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc_trans-84cc35c4fa80a856.so
#8  0x00007ffff5a66c36 in rustc_trans::base::trans_instance ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc_trans-84cc35c4fa80a856.so
#9  0x00007ffff5a97b75 in rustc_trans::trans_item::TransItemExt::define ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc_trans-84cc35c4fa80a856.so
#10 0x00007ffff5a6afc4 in rustc_trans::base::compile_codegen_unit ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc_trans-84cc35c4fa80a856.so
#11 0x00007ffff369af92 in rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::compute_result
    ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc-d6aca8ae434d20ce.so
#12 0x00007ffff3885ea1 in rustc::dep_graph::graph::DepGraph::with_task_impl ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc-d6aca8ae434d20ce.so
#13 0x00007ffff34be2d2 in rustc_errors::Handler::track_diagnostics ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc-d6aca8ae434d20ce.so
#14 0x00007ffff3a28240 in rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc-d6aca8ae434d20ce.so
#15 0x00007ffff369b03a in rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::force ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc-d6aca8ae434d20ce.so
#16 0x00007ffff369ba0f in rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::try_get ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc-d6aca8ae434d20ce.so
#17 0x00007ffff37b04bd in rustc::ty::maps::TyCtxtAt::compile_codegen_unit ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc-d6aca8ae434d20ce.so
#18 0x00007ffff3a4704a in rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::compile_codegen_unit ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc-d6aca8ae434d20ce.so
#19 0x00007ffff5a68f6e in rustc_trans::base::trans_crate ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc_trans-84cc35c4fa80a856.so
#20 0x00007ffff5af88c7 in <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::trans_crate ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/../lib/librustc_trans-84cc35c4fa80a856.so
#21 0x00007ffff7a356d8 in rustc::util::common::time ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/librustc_driver-33a33ebd533ddabe.so
#22 0x00007ffff7a61fae in rustc_driver::driver::phase_4_translate_to_llvm ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/librustc_driver-33a33ebd533ddabe.so
#23 0x00007ffff7aa5213 in rustc_driver::driver::compile_input::{{closure}} ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/librustc_driver-33a33ebd533ddabe.so
#24 0x00007ffff7a9aaa2 in <std::thread::local::LocalKey<T>>::with ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/librustc_driver-33a33ebd533ddabe.so
#25 0x00007ffff7a9e407 in <std::thread::local::LocalKey<T>>::with ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/librustc_driver-33a33ebd533ddabe.so
#26 0x00007ffff7ae98a8 in rustc::ty::context::TyCtxt::create_and_enter ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/librustc_driver-33a33ebd533ddabe.so
#27 0x00007ffff7a5d195 in rustc_driver::driver::compile_input ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/librustc_driver-33a33ebd533ddabe.so
#28 0x00007ffff7af6ca4 in rustc_driver::run_compiler ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/librustc_driver-33a33ebd533ddabe.so
#29 0x00007ffff7a3bed2 in std::sys_common::backtrace::__rust_begin_short_backtrace ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/librustc_driver-33a33ebd533ddabe.so
#30 0x00007ffff76a94bf in panic_unwind::__rust_maybe_catch_panic () at /checkout/src/libpanic_unwind/lib.rs:101
#31 0x00007ffff7ab8823 in <F as alloc::boxed::FnBox<A>>::call_box ()
   from /home/simon/tmp/servo-share/rust/1956d5535ad77ddf46e4b29ba089a8b4a73cfaea-alt/bin/../lib/librustc_driver-33a33ebd533ddabe.so
#32 0x00007ffff766567c in alloc::boxed::{{impl}}::call_once<(),()> () at /checkout/src/liballoc/boxed.rs:827
#33 std::sys_common::thread::start_thread () at /checkout/src/libstd/sys_common/thread.rs:24
#34 std::sys::unix::thread::{{impl}}::new::thread_start () at /checkout/src/libstd/sys/unix/thread.rs:90
#35 0x00007ffff166c7fc in start_thread (arg=0x7fffec1ff700) at pthread_create.c:465
#36 0x00007ffff734bb0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

@SimonSapin
Copy link
Contributor Author

This LLVM assertion fails in both debug and release mode, where as the division by zero in a "non-alt" compiler only happens in release mode. (Compilation succeeds in debug non-alt.)

@eddyb
Copy link
Member

eddyb commented Dec 5, 2017

@SimonSapin Any chance you can get a hold of a compiler with debug assertions enabled to get the last few lines of compilation with RUST_LOG=rustc_trans?

@SimonSapin
Copy link
Contributor Author

SimonSapin commented Dec 5, 2017

Sure.

INFO:rustc_trans::base: trans_instance(values::specified::font::FontFeatureSettings::system_font)
INFO:rustc_trans::base: trans_instance(values::specified::font::FontFeatureSettings::get_system)
INFO:rustc_trans::base: trans_instance(<values::specified::font::FontFeatureSettings as values::computed::ToComputedValue>::to_computed_value)
INFO:rustc_trans::base: trans_instance(<values::specified::font::FontFeatureSettings as values::computed::ToComputedValue>::from_computed_value)
INFO:rustc_trans::base: trans_instance(<values::specified::font::FontFeatureSettings as parser::Parse>::parse)
INFO:rustc_trans::base: trans_instance(<values::specified::font::FontSynthesis as parser::Parse>::parse)
INFO:rustc_trans::base: trans_instance(values::specified::font::FontLanguageOverride::system_font)
rustc: /checkout/src/llvm/include/llvm/Support/Casting.h:236: typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X = llvm::IntegerType; Y = llvm::Type; typename llvm::cast_retty<X, Y*>::ret_type = llvm::IntegerType*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
error: Could not compile `style`.

Type definition for the last one:

#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToCss)]
/// Allows authors to explicitly specify the language system of the font,
/// overriding the language system implied by the content language
pub enum FontLanguageOverride {
    /// When rendering with OpenType fonts,
    /// the content language of the element is
    /// used to infer the OpenType language system
    Normal,
    /// Single three-letter case-sensitive OpenType language system tag,
    /// specifies the OpenType language system to be used instead of
    /// the language system implied by the language of the element
    Override(Box<str>),
    /// Use system font
    System(SystemFont)
}

impl FontLanguageOverride {
    /// Get `font-language-override` with `system font`
    pub fn system_font(f: SystemFont) -> Self {
        FontLanguageOverride::System(f)
    }
}

        <%
            system_fonts = """caption icon menu message-box small-caption status-bar
                              -moz-window -moz-document -moz-workspace -moz-desktop
                              -moz-info -moz-dialog -moz-button -moz-pull-down-menu
                              -moz-list -moz-field""".split()
        %>

        #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToCss)]
        pub enum SystemFont {
            % for font in system_fonts:
                ${to_camel_case(font)},
            % endfor
        }

The second enum is generated by a Mako template, it looks like it’s "C-like"

@eddyb
Copy link
Member

eddyb commented Dec 5, 2017

Okay, so the culprit appears to be a missing check for uninhabited enums, between these lines:

pub fn trans_set_discr(&self, bcx: &Builder<'a, 'tcx>, variant_index: usize) {
match self.layout.variants {

The check should look like this:

    if self.layout.for_variant(bcx.ccx, variant_index).abi == layout::Abi::Uninhabited {
        return;
    }

This also lets us simplify an existing check:

if index != variant_index {
// If the layout of an enum is `Single`, all
// other variants are necessarily uninhabited.
assert_eq!(self.layout.for_variant(bcx.ccx, variant_index).abi,
layout::Abi::Uninhabited);
}

To just:

                assert_eq!(index, variant_index);

SimonSapin added a commit to SimonSapin/rust that referenced this issue Dec 5, 2017
bors added a commit that referenced this issue Dec 6, 2017
rustc_trans: don't write discriminants for uninhabited variants

Fixes #46519.

Patch as suggested by eddyb: #46519 (comment)
michaelwoerister pushed a commit to michaelwoerister/rust that referenced this issue Dec 7, 2017
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. regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Projects
None yet
Development

No branches or pull requests

4 participants