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

ICE with pyo3 on 1.31.0 nightly #55380

Closed
konstin opened this issue Oct 26, 2018 · 14 comments
Closed

ICE with pyo3 on 1.31.0 nightly #55380

konstin opened this issue Oct 26, 2018 · 14 comments
Assignees
Labels
A-specialization Area: Trait impl specialization I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@konstin
Copy link

konstin commented Oct 26, 2018

Pyo3 used to compile on 1.30 nightly, but is now failing with an ICE on 1.31

git clone https://github.com/pyo3/pyo3
git checkout b90d45d7e71de4fbb4d48083d64c47ba2735e5c7
cargo build
   Compiling pyo3 v0.5.0-alpha.1 (/home/konsti/pyo3)                                                                                                                         
error: internal compiler error: librustc/traits/specialize/mod.rs:104: When translating substitutions for specialization, the expected specialization failed to hold         
                                                                                                                                                                             
thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:600:9                                                                                                           
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::bug                                                                                                                                             
   8: rustc::util::bug::opt_span_bug_fmt::{{closure}}                                                                                                                        
   9: rustc::ty::context::tls::with_opt::{{closure}}                                                                                                                         
  10: rustc::ty::context::tls::with_context_opt                                                                                                                              
  11: rustc::ty::context::tls::with_opt                                                                                                                                      
  12: rustc::util::bug::opt_span_bug_fmt                                                                                                                                     
  13: rustc::util::bug::bug_fmt                                                                                                                                              
  14: rustc::traits::specialize::translate_substs::{{closure}}                                                                                                               
  15: rustc::traits::specialize::translate_substs                                                                                                                            
  16: rustc::ty::context::tls::with_related_context                                                                                                                          
  17: rustc::infer::InferCtxtBuilder::enter                                                                                                                                  
  18: rustc::traits::specialize::find_associated_item                                                                                                                        
  19: rustc::ty::instance::Instance::resolve                                                                                                                                 
  20: rustc_mir::lints::check                                                                                                                                                
  21: rustc::ty::context::tls::with_related_context                                                                                                                          
  22: rustc::infer::InferCtxtBuilder::enter                                                                                                                                  
  23: rustc_mir::build::mir_build                                                                                                                                            
  24: rustc_mir::transform::mir_built                                                                                                                                        
  25: rustc::ty::query::__query_compute::mir_built                                                                                                                           
  26: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::mir_built<'tcx>>::compute                                        
  27: rustc::ty::context::tls::with_context                                                                                                                                  
  28: rustc::dep_graph::graph::DepGraph::with_task_impl                                                                                                                      
  29: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start                                                                                                             
  30: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job                                                                    
  31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query                                                                               
  32: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_built                                                                                         
  33: rustc_mir::transform::check_unsafety::unsafety_check_result                                                                                                            
  34: rustc::ty::query::__query_compute::unsafety_check_result                                                                                                               
  35: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::unsafety_check_result<'tcx>>::compute                            
  36: rustc::ty::context::tls::with_context                                                                                                                                  
  37: rustc::dep_graph::graph::DepGraph::with_task_impl                                                                                                                      
  38: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start                                                                                                             
  39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job                                                                    
  40: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query                                                                               
  41: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::unsafety_check_result                                                                             
  42: rustc_mir::transform::mir_const                                                                                                                                        
  43: rustc::ty::query::__query_compute::mir_const                                                                                                                           
  44: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::mir_const<'tcx>>::compute                                        
  45: rustc::ty::context::tls::with_context                                                                                                                                  
  46: rustc::dep_graph::graph::DepGraph::with_task_impl                                                                                                                      
  47: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start                                                                                                             
  48: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job                                                                    
  49: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query                                                                               
  50: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_const                                                                                         
  51: rustc_mir::transform::mir_validated                                                                                                                                    
  52: rustc::ty::query::__query_compute::mir_validated                                                                                                                       
  53: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::mir_validated<'tcx>>::compute                                    
  54: rustc::ty::context::tls::with_context                                                                                                                                  
  55: rustc::dep_graph::graph::DepGraph::with_task_impl                                                                                                                      
  56: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start                                                                                                             
  57: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job                                                                    
  58: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query                                                                               
  59: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query                                                                            
  60: rustc_borrowck::borrowck::borrowck                                                                                                                                     
  61: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::borrowck<'tcx>>::compute                                         
  62: rustc::ty::context::tls::with_context                                                                                                                                  
  63: rustc::dep_graph::graph::DepGraph::with_task_impl                                                                                                                      
  64: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start                                                                                                             
  65: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job                                                                    
  66: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query                                                                               
  67: rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::par_body_owners                                                                                          
  68: rustc_borrowck::borrowck::check_crate                                                                                                                                  
  69: rustc::util::common::time                                                                                                                                              
  70: rustc::ty::context::tls::enter_context                                                                                                                                 
  71: <std::thread::local::LocalKey<T>>::with                                                                                                                                
  72: rustc::ty::context::TyCtxt::create_and_enter                                                                                                                           
  73: rustc_driver::driver::compile_input                                                                                                                                    
  74: rustc_driver::run_compiler_with_pool                                                                                                                                   
  75: rustc_driver::driver::spawn_thread_pool                                                                                                                                
  76: rustc_driver::run_compiler                                                                                                                                             
  77: <scoped_tls::ScopedKey<T>>::set                                                                                                                                        
  78: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once                                                                                        
  79: __rust_maybe_catch_panic                                                                                                                                               
             at libpanic_unwind/lib.rs:102                                                                                                                                   
  80: rustc_driver::run                                                                                                                                                      
  81: rustc_driver::main                                                                                                                                                     
  82: std::rt::lang_start::{{closure}}                                                                                                                                       
  83: std::panicking::try::do_call                                                                                                                                           
             at libstd/rt.rs:59                                                                                                                                              
             at libstd/panicking.rs:310                                                                                                                                      
  84: __rust_maybe_catch_panic                                                                                                                                               
             at libpanic_unwind/lib.rs:102                                                                                                                                   
  85: std::rt::lang_start_internal                                                                                                                                           
             at libstd/panicking.rs:289                                                                                                                                      
             at libstd/panic.rs:392                                                                                                                                          
             at libstd/rt.rs:58                                                                                                                                              
  86: main                                                                                                                                                                   
  87: __libc_start_main                                                                                                                                                      
  88: <unknown>                                                                                                                                                              
query stack during panic:                                                                                                                                                    
#0 [mir_built] processing `freelist::<impl typeob::PyObjectAlloc<T> for T>::dealloc`                                                                                         
#1 [unsafety_check_result] processing `freelist::<impl typeob::PyObjectAlloc<T> for T>::dealloc`                                                                             
#2 [mir_const] processing `freelist::<impl typeob::PyObjectAlloc<T> for T>::dealloc`                                                                                         
#3 [mir_validated] processing `freelist::<impl typeob::PyObjectAlloc<T> for T>::dealloc`                                                                                     
#4 [borrowck] processing `freelist::<impl typeob::PyObjectAlloc<T> for T>::dealloc`                                                                                          
end of query stack                                                                                                                                                           
error: aborting due to previous error                                                                                                                                        
                                                                                                                                                                             
                                                                                                                                                                             
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 (4bd4e4130 2018-10-25) 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 `pyo3`.                                                                                                                                             

To learn more, run the command again with --verbose.
@kngwyu
Copy link
Contributor

kngwyu commented Oct 26, 2018

I checked we can compile it with nightly-2018-10-24-x86_64-unknown-linux-gnu

@estebank estebank added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Oct 26, 2018
@kngwyu
Copy link
Contributor

kngwyu commented Oct 27, 2018

I made a minimal example

@kngwyu
Copy link
Contributor

kngwyu commented Oct 28, 2018

I tried compile with some revisions and found it can compile before #54490 is merged.

@auscompgeek
Copy link

Dunno how useful this is, but @kngwyu's minimal example can be further minimised slightly by changing line 5 to unsafe fn drop();.

@anyputer
Copy link

Same exact error

@matthiaskrgr
Copy link
Member

This ICE also triggers when building the following crates:

compact-0.2.5
compact-0.2.13
compact-0.2.7
descartes-0.1.10
descartes-0.1.13
descartes-0.1.4
descartes-0.1.8
michelangelo-0.1.1

akshayknarayan added a commit to ccp-project/portus that referenced this issue Nov 6, 2018
Due to rust-lang/rust#55380, travis cannot
compile pyportus. These failures mask other real errors. Therefore,
temporarily disable travis builds of the python bindings until either:
1. we can specify rust nightly version in travis
2. ICE goes away.
akshayknarayan added a commit to ccp-project/portus that referenced this issue Nov 6, 2018
Due to rust-lang/rust#55380, travis cannot
compile pyportus. These failures mask other real errors. Therefore,
temporarily disable travis builds of the python bindings until either:
1. we can specify rust nightly version in travis
2. ICE goes away.
akshayknarayan added a commit to ccp-project/portus that referenced this issue Nov 6, 2018
Due to rust-lang/rust#55380, travis cannot
compile pyportus. These failures mask other real errors. Therefore,
pin travis builds to rust nightly-2018-10-23 until ICE is resolved (or
pyo3 0.5.0 is released, which will resolve this).
akshayknarayan added a commit to ccp-project/portus that referenced this issue Nov 6, 2018
Due to rust-lang/rust#55380, travis cannot
compile pyportus. These failures mask other real errors.

Could not pin travis builds to rust nightly-2018-10-23 until ICE is resolved (or
pyo3 0.5.0 is released, which will resolve this).

Disable travis builds of python bindings temporarily.
@matthiaskrgr
Copy link
Member

I just stumbled upon this again while analyzing some ICEs on crater runs.
When checking compact 0.2.13, this ICEs rustc 1.31.0-beta.19 (42053f9f0 2018-11-26) and rustc 1.32.0-nightly (3e90a12a8 2018-11-29) but works with rustc 1.30.1 (1433507eb 2018-11-07)

@Centril Centril added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Nov 30, 2018
@arielb1 arielb1 added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-specialization Area: Trait impl specialization labels Dec 2, 2018
@arielb1
Copy link
Contributor

arielb1 commented Dec 2, 2018

This regression seems to depend on specialization, which is unstable, so this is a nightly-to-nightly
regression rather than a stable-to-nightly regression.

Of course, this is indeed a regression and should be resolved, but there is no point in e.g. beta-nominating it.

@matthiaskrgr
Copy link
Member

Ah sorry, my bad then (being the one asking for the from-stable-to-nightly to be added).

@arielb1
Copy link
Contributor

arielb1 commented Dec 2, 2018

@matthiaskrgr

No problem. I just wanted us on the compiler team to be aware of what is going on here.

@arielb1
Copy link
Contributor

arielb1 commented Dec 2, 2018

Even more minified:

#![feature(specialization)]

pub trait Foo {
    fn abc();
    fn def();
}

pub trait Marker {}

impl Marker for () {}

impl<T> Foo for T {
    default fn abc() {}
    default fn def() {}
}

impl<T: Marker> Foo for T {
    fn def() {
        Self::abc();
    }
}

fn main() {
    <()>::def();
    <i32>::def();
}

@arielb1
Copy link
Contributor

arielb1 commented Dec 2, 2018

I think I found the bug, but not the commit that introduced the regression (am testing locally). I think #54490 was responsible for the regression? (It is not to blame for the bug).

@arielb1
Copy link
Contributor

arielb1 commented Dec 2, 2018

The fix is fundamentally:

@@ -119,10 +121,13 @@ pub fn translate_substs<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
 /// whichever applies.
 pub fn find_associated_item<'a, 'tcx>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
+    param_env: ty::ParamEnv<'tcx>,
     item: &ty::AssociatedItem,
     substs: &'tcx Substs<'tcx>,
     impl_data: &super::VtableImplData<'tcx, ()>,
 ) -> (DefId, &'tcx Substs<'tcx>) {
+    debug!("find_associated_item({:?}, {:?}, {:?}, {:?})",
+           param_env, item, substs, impl_data);
     assert!(!substs.needs_infer());
 
     let trait_def_id = tcx.trait_id_of_impl(impl_data.impl_def_id).unwrap();
@@ -132,7 +137,7 @@ pub fn find_associated_item<'a, 'tcx>(
     match ancestors.defs(tcx, item.ident, item.kind, trait_def_id).next() {
         Some(node_item) => {
             let substs = tcx.infer_ctxt().enter(|infcx| {
-                let param_env = ty::ParamEnv::reveal_all();
+                let param_env = param_env.with_reveal_all();
                 let substs = substs.rebase_onto(tcx, trait_def_id, impl_data.substs);
                 let substs = translate_substs(&infcx, param_env, impl_data.impl_def_id,
                                               substs, node_item.node);

arielb1 added a commit to arielb1/rust that referenced this issue Dec 2, 2018
dropping the param-env on the floor is obviously the wrong thing to do.

The ICE was probably exposed by rust-lang#54490 adding the problem-exposing use of
`traits::find_associated_item`.

Fixes rust-lang#55380.
pietroalbini added a commit to pietroalbini/rust that referenced this issue Dec 5, 2018
…=nikomatsakis

pass the parameter environment to `traits::find_associated_item`

dropping the param-env on the floor is obviously the wrong thing to do.

The ICE was probably exposed by rust-lang#54490 adding the problem-exposing use of
`traits::find_associated_item`.

Fixes rust-lang#55380.

r? @nikomatsakis
pietroalbini added a commit to pietroalbini/rust that referenced this issue Dec 6, 2018
…=nikomatsakis

pass the parameter environment to `traits::find_associated_item`

dropping the param-env on the floor is obviously the wrong thing to do.

The ICE was probably exposed by rust-lang#54490 adding the problem-exposing use of
`traits::find_associated_item`.

Fixes rust-lang#55380.

r? @nikomatsakis
@pnkfelix
Copy link
Member

pnkfelix commented Dec 6, 2018

triage. P-high. Removing stable-to-nightly regression label in accordance with @arielb1 's note above that this example is relying on an unstable feature. Assigning to @arielb1 (who has put up a PR fixing it in any case).

@pnkfelix pnkfelix added P-high High priority and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Dec 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-specialization Area: Trait impl specialization I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority 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

9 participants