rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.74k stars 12.5k forks source link

ICE: broken MIR in DefId #55241

Closed Robbepop closed 5 years ago

Robbepop commented 5 years ago

When compiling paritytech/parity-common workspace using cargo test --features std.

As far as the error shows it has something to do with the patricia_trie sub crate.

Compiler output:

error: internal compiler error: broken MIR in DefId(0/0:377 ~ patricia_trie[2708]::Trie[0]::is_empty[0]) (NoSolution): failed to normalize `<_ as hashdb::Hasher>::Out`                                                                                       

error: internal compiler error: broken MIR in DefId(0/0:129 ~ patricia_trie[2708]::triedbmut[0]::{{impl}}[5]::new[0]) (NoSolution): failed to normalize `<_ as hashdb::Hasher>::Out`                                                                          

error: internal compiler error: broken MIR in DefId(0/0:146 ~ patricia_trie[2708]::triedbmut[0]::{{impl}}[6]::is_empty[0]) (NoSolution): failed to normalize `<_ as hashdb::Hasher>::Out`                                                                     

error: internal compiler error: broken MIR in DefId(0/0:149 ~ patricia_trie[2708]::triedbmut[0]::{{impl}}[6]::remove[0]) (NoSolution): failed to normalize `<_ as hashdb::Hasher>::Out`                                                                       

thread 'main' panicked at 'no errors encountered even though `delay_span_bug` issued', librustc_errors/lib.rs:334:17                                                                                                                                          
stack backtrace:                                                                                                                                                                                                                                              
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace                                                                                                                                                                                               
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49                                                                                                                                                                                                 
   1: std::sys_common::backtrace::print                                                                                                                                                                                                                       
             at libstd/sys_common/backtrace.rs:71                                                                                                                                                                                                             
             at libstd/sys_common/backtrace.rs:59                                                                                                                                                                                                             
   2: std::panicking::default_hook::{{closure}}                                                                                                                                                                                                               
             at libstd/panicking.rs:211                                                                                                                                                                                                                       
   3: std::panicking::default_hook                                                                                                                                                                                                                            
             at libstd/panicking.rs:227                                                                                                                                                                                                                       
   4: rustc::util::common::panic_hook                                                                                                                                                                                                                         
   5: std::panicking::rust_panic_with_hook                                                                                                                                                                                                                    
             at libstd/panicking.rs:480                                                                                                                                                                                                                       
   6: std::panicking::begin_panic                                                                                                                                                                                                                             
   7: <rustc_errors::Handler as core::ops::drop::Drop>::drop                                                                                                                                                                                                  
   8: core::ptr::drop_in_place                                                                                                                                                                                                                                
   9: core::ptr::drop_in_place                                                                                                                                                                                                                                
  10: core::ptr::drop_in_place                                                                                                                                                                                                                                
  11: <scoped_tls::ScopedKey<T>>::set                                                                                                                                                                                                                         
  12: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once                                                                                                                                                                         
  13: __rust_maybe_catch_panic                                                                                                                                                                                                                                
             at libpanic_unwind/lib.rs:102                                                                                                                                                                                                                    
  14: rustc_driver::run                                                                                                                                                                                                                                       
  15: rustc_driver::main                                                                                                                                                                                                                                      
  16: std::rt::lang_start::{{closure}}                                                                                                                                                                                                                        
  17: std::panicking::try::do_call                                                                                                                                                                                                                            
             at libstd/rt.rs:59                                                                                                                                                                                                                               
             at libstd/panicking.rs:310                                                                                                                                                                                                                       
  18: __rust_maybe_catch_panic                                                                                                                                                                                                                                
             at libpanic_unwind/lib.rs:102                                                                                                                                                                                                                    
  19: std::rt::lang_start_internal                                                                                                                                                                                                                            
             at libstd/panicking.rs:289                                                                                                                                                                                                                       
             at libstd/panic.rs:392                                                                                                                                                                                                                           
             at libstd/rt.rs:58                                                                                                                                                                                                                               
  20: main                                                                                                                                                                                                                                                    
  21: __libc_start_main                                                                                                                                                                                                                                       
  22: <unknown>                                                                                                                                                                                                                                               
query stack during panic:                                                                                                                                                                                                                                     
end of query stack                                                                                                                                                                                                                                            

error: internal compiler error: unexpected panic                                                                                                                                                                                                              

note: the compiler unexpectedly panicked. this is a bug.                                                                                                                                                                                                      

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports                                                                                                                                             

note: rustc 1.31.0-nightly (78ff609d7 2018-10-19) running on x86_64-unknown-linux-gnu                                                                                                                                                                         

note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib                                                                                                                                                                                          

note: some of the compiler flags provided by cargo are hidden                                                                                                                                                                                                 

error: Could not compile `patricia-trie`.                                                                                                                                                                                                                     
warning: build failed, waiting for other jobs to finish...
error: build failed
matthewjasper commented 5 years ago

cc @nikomatsakis

myrrlyn commented 5 years ago

I think I have a similar ICE. The exact ICE point is:

'assertion failed: !impl_self_ty.has_infer_types()', librustc_mir/borrow_check/nll/type_check/mod.rs:1033:21

I have a snapshot of my project at https://files.myrrlyn.net/cosmonaut-ice-20181021.tar.xz

See the files ice/20181021.* for information and the backtrace.

pnkfelix commented 5 years ago

assigning to self to reduce to a smaller test case.

nikomatsakis commented 5 years ago

Marking as an RC2 blocker -- though it might be better to shoot for a backport?

nikomatsakis commented 5 years ago

I think we decided to push this to Rust 2018 release

nikomatsakis commented 5 years ago

I just tested and this still seems to reproduce with https://github.com/rust-lang/rust/pull/55229 :(

nikomatsakis commented 5 years ago

OK, I have a fix for this.

nikomatsakis commented 5 years ago

I did not yet manage to crate a narrowed test case for this particular case — it seems like a several similar root problem to #55219 though.

nikomatsakis commented 5 years ago

OK, here is a standalone test case:

#![feature(nll)]

pub trait Hasher {
    type Out: Eq;
}

pub trait NodeCodec<H: Hasher> {
    const HASHED_NULL_NODE: H::Out;
}

pub trait Trie<H: Hasher, C: NodeCodec<H>> {
    fn root(&self) -> &H::Out;

    fn is_empty(&self) -> bool { *self.root() == C::HASHED_NULL_NODE }
}

fn main() { }