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

error: internal compiler error: unexpected panic #43774

Closed
IgnusG opened this issue Aug 9, 2017 · 2 comments
Closed

error: internal compiler error: unexpected panic #43774

IgnusG opened this issue Aug 9, 2017 · 2 comments
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@IgnusG
Copy link

IgnusG commented Aug 9, 2017

So I was messing around with iterators and created this horrific creature while struggling with shuffling around lifetimes and borrows:

fn prepare_async_listen<'a> (listener: &TcpListener) -> Result<impl Fn(&TcpListener) -> Result<Box<impl Iterator<Item=&TcpStream> + 'a>>> {
    let poll = Poll::new()
        .chain_err(|| "couldn't create poll")?;

    poll.register(listener, Token(0), Ready::readable() | Ready::writable(), PollOpt::edge())
        .chain_err(|| "couldn't register listener on poll")?;

    Ok(move |listener: &TcpListener| {
        let mut events = Events::with_capacity(1024);

        poll.poll(&mut events, Some(Duration::from_millis(100)))
            .chain_err(|| "polling failed")?;
        Ok(Box::new(events.iter().map(|_| &listener.accept().unwrap().0)))
    })
}

let listener = TcpListener::bind(&socket)
    .chain_err(|| "listener couldn't bind socket")?;
let async_listen = prepare_async_listen(&listener)?;

while !should_die.get() {
    trace_labeled_error!( format!("{} listener encountered a problem", desc), {
        for stream in async_listen(&listener)? {
            tx.send(stream_type(stream))
                .chain_err(|| "sending stream to core channel failed")?;
        };
    });
};

The compiler seemed so confused that it let me proceed with it and everything broke. This is the backtrace:

thread 'rustc' panicked at 'assertion failed: match *region { ty::ReLateBound(..) => false, _ => true, }', /checkout/src/librustc/infer/higher_ranked/mod.rs:493:8
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:380
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:390
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:611
   5: std::panicking::begin_panic_new
   6: rustc::infer::higher_ranked::fold_regions_in::{{closure}}
   7: rustc::ty::fold::TypeFolder::fold_ty
   8: rustc::infer::InferCtxt::match_poly_projection_predicate
   9: rustc::traits::project::confirm_param_env_candidate
  10: rustc::traits::project::confirm_candidate
  11: rustc::traits::project::opt_normalize_projection_type
  12: rustc::traits::project::normalize_projection_type
  13: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  14: rustc::traits::project::opt_normalize_projection_type
  15: rustc::traits::project::normalize_projection_type
  16: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  17: rustc::traits::project::opt_normalize_projection_type
  18: rustc::traits::project::poly_project_and_unify_type::{{closure}}
  19: rustc::traits::project::poly_project_and_unify_type
  20: <rustc::traits::fulfill::FulfillProcessor<'a, 'b, 'gcx, 'tcx> as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation
  21: rustc::traits::fulfill::FulfillmentContext::select
  22: rustc::traits::fulfill::FulfillmentContext::select_where_possible
  23: rustc_typeck::check::FnCtxt::select_obligations_where_possible
  24: rustc_typeck::check::FnCtxt::check_argument_types
  25: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::confirm_builtin_call
  26: rustc_typeck::check::FnCtxt::check_expr_kind
  27: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  28: rustc_typeck::check::FnCtxt::check_expr_meets_expectation_or_error
  29: rustc_typeck::check::FnCtxt::check_expr_kind
  30: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  31: rustc_typeck::check::FnCtxt::check_decl_local
  32: rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}
  33: rustc_typeck::check::FnCtxt::check_block_with_expected
  34: rustc_typeck::check::FnCtxt::check_expr_kind
  35: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  36: rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}
  37: rustc_typeck::check::FnCtxt::check_block_with_expected
  38: rustc_typeck::check::FnCtxt::check_expr_kind
  39: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  40: rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}
  41: rustc_typeck::check::FnCtxt::check_block_with_expected
  42: rustc_typeck::check::FnCtxt::check_expr_kind
  43: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  44: rustc_typeck::check::FnCtxt::check_return_expr
  45: rustc_typeck::check::check_fn
  46: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_closure
  47: rustc_typeck::check::FnCtxt::check_expr_kind
  48: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  49: rustc_typeck::check::FnCtxt::check_expr_kind
  50: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  51: rustc_typeck::check::FnCtxt::check_expr_kind
  52: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  53: rustc_typeck::check::FnCtxt::check_argument_types
  54: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::confirm_builtin_call
  55: rustc_typeck::check::FnCtxt::check_expr_kind
  56: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  57: rustc_typeck::check::FnCtxt::check_expr_meets_expectation_or_error
  58: rustc_typeck::check::FnCtxt::check_expr_kind
  59: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  60: rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}
  61: rustc_typeck::check::FnCtxt::check_block_with_expected
  62: rustc_typeck::check::FnCtxt::check_expr_kind
  63: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  64: rustc_typeck::check::FnCtxt::check_return_expr
  65: rustc_typeck::check::check_fn
  66: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_closure
  67: rustc_typeck::check::FnCtxt::check_expr_kind
  68: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  69: rustc_typeck::check::FnCtxt::check_expr_kind
  70: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  71: rustc_typeck::check::FnCtxt::check_expr_kind
  72: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  73: rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}
  74: rustc_typeck::check::FnCtxt::check_block_with_expected
  75: rustc_typeck::check::FnCtxt::check_expr_kind
  76: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  77: rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}
  78: rustc_typeck::check::FnCtxt::check_block_with_expected
  79: rustc_typeck::check::FnCtxt::check_expr_kind
  80: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  81: rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}
  82: rustc_typeck::check::FnCtxt::check_block_with_expected
  83: rustc_typeck::check::FnCtxt::check_expr_kind
  84: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  85: rustc_typeck::check::FnCtxt::check_return_expr
  86: rustc_typeck::check::check_fn
  87: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_closure
  88: rustc_typeck::check::FnCtxt::check_expr_kind
  89: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  90: rustc_typeck::check::FnCtxt::check_expr_kind
  91: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  92: rustc_typeck::check::FnCtxt::check_expr_kind
  93: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  94: rustc_typeck::check::FnCtxt::check_argument_types
  95: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::confirm_builtin_call
  96: rustc_typeck::check::FnCtxt::check_expr_kind
  97: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  98: rustc_typeck::check::FnCtxt::check_expr_meets_expectation_or_error
  99: rustc_typeck::check::FnCtxt::check_expr_kind

It told me to report this error so I did but honestly any help with getting that code above to compile would be appreciated because that backtrace is way over my skill level and I don't know what to do with it.

Some meta:

rustc 1.20.0-nightly (9b85e1cfa 2017-07-07)
binary: rustc
commit-hash: 9b85e1cfa5aa2aaa4b5df4359a023ad793983ffc
commit-date: 2017-07-07
host: x86_64-unknown-linux-gnu
release: 1.20.0-nightly
LLVM version: 4.0

Built using mio crate and #![feature(conservative_impl_trait)]

@kennytm
Copy link
Member

kennytm commented Aug 9, 2017

Possibly a duplicate of #39553.

@Mark-Simulacrum Mark-Simulacrum added A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. labels Aug 10, 2017
@Mark-Simulacrum
Copy link
Member

Closing in favor of #39553.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

3 participants