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: unexpected panic in InferCtxt #28550

Closed
khernyo opened this issue Sep 20, 2015 · 4 comments
Closed

ICE: unexpected panic in InferCtxt #28550

khernyo opened this issue Sep 20, 2015 · 4 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@khernyo
Copy link
Contributor

khernyo commented Sep 20, 2015

Compiling the following code causes a panic:

use std::result::Result;
use std::thread;

struct A<H: B> {
    t: H::Timeout,
}

trait B {
    type Timeout;
}

struct C<F> where F: Factory {
    f: F,
}

impl<F> B for C <F> where F: Factory {
    type Timeout = ();
}

struct D<F> where F: Factory {
    a: A<C<F>>,
}

impl<F> D<F> where F: Factory {
    fn new(f: F) -> Result<D<F>, ()> {
        panic!();
    }
}

trait Factory {
}

impl<F, H> Factory for F where H: Handler, F: FnMut(i32) -> H {
}

trait Handler {
}

impl<F> Handler for F where F: Fn(i32) -> () {
}

fn main() {
    thread::spawn(move || {
        D::new(|_| { move |_| { () } });
    });
}

Compiler output:

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
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:365

stack backtrace:
   1:     0x7fdef400af19 - sys::backtrace::tracing::imp::write::hd3f07380f094c3d8Pnt
   2:     0x7fdef4008736 - panicking::on_panic::hbcd77a06a59b411aenx
   3:     0x7fdef3fd503e - sys_common::unwind::begin_unwind_inner::h57bfaf3a147bd49affs
   4:     0x7fdef3fd5a78 - sys_common::unwind::begin_unwind_fmt::h86f74adb98a0354bles
   5:     0x7fdef40081d1 - rust_begin_unwind
   6:     0x7fdef4054acf - panicking::panic_fmt::hb3d424cb509d7c29TaG
   7:     0x7fdef404e0e8 - panicking::panic::hea7947f7c1336ee9q9F
   8:     0x7fdef1e344fa - middle::infer::InferCtxt<'a, 'tcx>::closure_type::hb9fca2654a1e5eebd1C
   9:     0x7fdef1eafd38 - middle::traits::select::SelectionContext<'cx, 'tcx>::closure_trait_ref_unnormalized::haf9984e1bd3a2127ImX
  10:     0x7fdef1d8d259 - middle::traits::select::SelectionContext<'cx, 'tcx>::select::hb6b9ab80b7d40addudU
  11:     0x7fdef1e942f3 - middle::traits::fulfill::process_predicate::h777636d2b6e7bc0dx5R
  12:     0x7fdef1e92c81 - middle::traits::fulfill::FulfillmentContext<'tcx>::select::h2760b340d700acc6ZYR
  13:     0x7fdef1e927d7 - middle::traits::fulfill::FulfillmentContext<'tcx>::select_where_possible::hddcd4049e7010152tXR
  14:     0x7fdef1d38e23 - middle::traits::fulfill::FulfillmentContext<'tcx>::select_all_or_error::h4c3a89434e3357a6SVR
  15:     0x7fdef1e3359f - middle::traits::type_known_to_meet_builtin_bound::h1b4c4c37c2c4a2e0D3Y
  16:     0x7fdef1ee1c0b - middle::ty::util::ty..TyS<'tcx>::impls_bound::h02e3d047f5e01c50FW4
  17:     0x7fdef1e3372f - middle::ty::util::ty..TyS<'tcx>::moves_by_default::hb1722bfd58f33277WY4
  18:     0x7fdef1da6df2 - middle::expr_use_visitor::copy_or_move::h420c1a217b76bfa95Nr
  19:     0x7fdef1d34e66 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::consume_expr::hdc82c412b9ba9053snq
  20:     0x7fdef1d7f394 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::walk_expr::hc7978fbe900003fdLvq
  21:     0x7fdef1d34eae - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::consume_expr::hdc82c412b9ba9053snq
  22:     0x7fdef1d3660a - middle::expr_use_visitor::ExprUseVisitor<'d, 't, 'a, 'tcx>::walk_fn::h422f97948c1a8175Lhq
  23:     0x7fdef2b618dd - check::upvar::AdjustBorrowKind<'a, 'tcx>.Visitor<'v>::visit_fn::h76010959033c9b35Cbk
  24:     0x7fdef2b61550 - visit::walk_expr::h16181555174029332073
  25:     0x7fdef2b6124e - visit::walk_expr::h16181555174029332073
  26:     0x7fdef2ba58f5 - check::check_bare_fn::h1b9a831a51795dbcozp
  27:     0x7fdef2ba3310 - check::check_item_body::h223ccbb34dff59e3I0p
  28:     0x7fdef2c59cd2 - check_crate::h85ae42a95dc44b30GCE
  29:     0x7fdef4528c9e - driver::phase_3_run_analysis_passes::closure.21538
  30:     0x7fdef450b3bc - middle::ty::context::ctxt<'tcx>::create_and_enter::h14072355153472622424
  31:     0x7fdef4506b71 - driver::phase_3_run_analysis_passes::h5404249183138524855
  32:     0x7fdef44e74c3 - driver::compile_input::h813f6e216bee01860ba
  33:     0x7fdef464d02b - run_compiler::heebf093ad18f383a3qc
  34:     0x7fdef464a896 - boxed::F.FnBox<A>::call_box::h5441627487340085045
  35:     0x7fdef464a1a4 - sys_common::unwind::try::try_fn::h12996996568669864182
  36:     0x7fdef4008038 - __rust_try
  37:     0x7fdef3ffc832 - sys_common::unwind::try::inner_try::hc22680ca31a93181Dbs
  38:     0x7fdef464a33e - boxed::F.FnBox<A>::call_box::h4646831150340203223
  39:     0x7fdef4010233 - sys::thread::Thread::new::thread_start::h4012f549bc8d9354dGw
  40:     0x7fdeed5910a3 - start_thread
  41:     0x7fdef3c9106c - clone
  42:                0x0 - <unknown>

I compiled with rustc main.rs

Meta

rustc 1.5.0-nightly (6e5a325 2015-09-19)
binary: rustc
commit-hash: 6e5a325
commit-date: 2015-09-19
host: x86_64-unknown-linux-gnu
release: 1.5.0-nightly

@Stebalien
Copy link
Contributor

Reduced test case:

// Using F directly causes it to compile.
struct A<F: FnOnce()>(F::Output);
struct B<F: FnOnce()>(A<F>);

// Removing Option causes it to compile.
fn foo<F: FnOnce()>(f: F) -> Option<B<F>> {
    panic!()
}

fn main() {
    || foo(||());
}

@sanxiyn sanxiyn added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 22, 2015
@arielb1 arielb1 added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Sep 24, 2015
@arielb1
Copy link
Contributor

arielb1 commented Sep 24, 2015

This is a 1.3-1.4 regression.

I accidentally caused it in 9b75a2b.

@alexcrichton
Copy link
Member

triage: I-nominated

@alexcrichton alexcrichton added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 24, 2015
@nikomatsakis
Copy link
Contributor

triage: P-medium

@rust-highfive rust-highfive added P-medium Medium priority and removed I-nominated labels Oct 1, 2015
brson pushed a commit to brson/rust that referenced this issue Oct 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. 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

7 participants