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: TypeParameterDef lookup failure in tc_ty #16643

Closed
kmcallister opened this issue Aug 21, 2014 · 3 comments · Fixed by #16753
Closed

ICE: TypeParameterDef lookup failure in tc_ty #16643

kmcallister opened this issue Aug 21, 2014 · 3 comments · Fixed by #16753
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@kmcallister
Copy link
Contributor

Extracted from an issue I encountered upgrading html5ever to Rust master.

foo.rs:

#![crate_type="lib"]

pub trait TokenSink {
    fn process_token(&self, token: ());
}

pub struct TreeBuilder<Handle> {
    pub open_elems: Vec<Handle>,
}

impl<Handle> TokenSink for TreeBuilder<Handle> {
    fn process_token(&self, token: ()) {
        match token {
            _ => for x in self.open_elems.iter() { },
        }
    }
}

bar.rs:

extern crate foo;

use foo::{TreeBuilder, TokenSink};

fn main() {
    let tb: TreeBuilder<uint> = TreeBuilder {
        open_elems: vec!(),
    };
    tb.process_token(());
}

It seems like more or less every part of this code is necessary to hit the bug. Here's the result:

$ rustc -v
rustc 0.12.0-pre (e11cb5bba 2014-08-20 16:25:53 +0000)

$ rustc foo.rs

$ RUST_BACKTRACE=1 rustc -L. bar.rs
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'TypeParameterDef lookup failed for ParamTy { space: TypeSpace, idx: 0, def_id: DefId { krate: 0, node: 598 } }', /home/keegan/rust/src/librustc/middle/ty.rs:2294

stack backtrace:
   1:     0x7f12658b8a20 - rt::backtrace::imp::write::hd65c9804462fb8dcpxr
   2:     0x7f12658bb3e0 - failure::on_fail::hb34a0faf07b986176Sr
   3:     0x7f126a2ed030 - unwind::begin_unwind_inner::hfc98b793f314ea06pie
   4:     0x7f126a2ecb30 - unwind::begin_unwind_fmt::he2958ada65c1d41fPfe
   5:     0x7f126b53a670 - middle::ty::type_contents::tc_ty::h98abbbfc60a7d554waG
   6:     0x7f126b53a670 - middle::ty::type_contents::tc_ty::h98abbbfc60a7d554waG
   7:     0x7f126af18a50 - middle::ty::type_contents::h1b7aa404dfcb34d1r9F
   8:     0x7f126ae63e00 - middle::ty::type_moves_by_default::h8602de8843dbf54dcrG
   9:     0x7f126ada8ac0 - middle::expr_use_visitor::copy_or_move::h0d63d7bcb9e1b5295zv
  10:     0x7f126b417b50 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_pat::closure.118640
  11:     0x7f126b412d60 - middle::mem_categorization::MemCategorizationContext<'t, TYPER>::cat_pattern::h1612630838218560840
  12:     0x7f126b4127b0 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_pat::h17289765959183890288
  13:     0x7f126b4059c0 - middle::expr_use_visitor::ExprUseVisitor<'d, 't, TYPER>::walk_expr::h18108696973096423772
  14:     0x7f126b405430 - middle::trans::_match::is_discr_reassigned::ha03b6a6c6923b1b8MQh
  15:     0x7f126b41ab90 - middle::trans::_match::create_bindings_map::h5a49a20efb57c753jUh
  16:     0x7f126b4216e0 - middle::trans::_match::trans_match_inner::closure.118687
  17:     0x7f126b420630 - iter::Map<'a, A, B, T>::do_map::h4328457525798762931
  18:     0x7f126b4205c0 - iter::Map<'a, A, B, T>.Iterator<B>::next::h14044686831652860284
  19:     0x7f126b420570 - iter::ByRef<'a, T>.Iterator<A>::next::h7270709296560143036
  20:     0x7f126b420100 - vec::Vec<T>.FromIterator<T>::from_iter::h13079317938292968767
  21:     0x7f126b4200a0 - iter::Iterator::collect::h10157566076738839025
  22:     0x7f126b404a90 - middle::trans::_match::trans_match_inner::h3199dcbd82cb2abfAXh
  23:     0x7f126b2df4c0 - middle::trans::_match::trans_match::h1d773729c0952ac6XPh
  24:     0x7f126b2c5b40 - middle::trans::expr::trans_rvalue_dps_unadjusted::h68c42f27e53f341euG3
  25:     0x7f126b2610c0 - middle::trans::expr::trans_into::h02f395bc1df027d3QL2
  26:     0x7f126b2617e0 - middle::trans::controlflow::trans_block::h05731a7862534d438MY
  27:     0x7f126b3b30f0 - middle::trans::base::trans_closure::h761f159ac0f5b1d5Zve
  28:     0x7f126b24a4a0 - middle::trans::base::trans_fn::h7f652b8e491f5fceNIe
  29:     0x7f126b24ad10 - middle::trans::monomorphize::monomorphic_fn::h444eefff2433fcd158X
  30:     0x7f126b2a3ed0 - middle::trans::callee::trans_fn_ref_with_vtables::hbc4955abe0c5e25axp1
  31:     0x7f126b2a15b0 - middle::trans::callee::trans_fn_ref::h8cbdc53077e7d865za1
  32:     0x7f126b273f50 - middle::trans::meth::trans_method_callee::hd255bf18a4fec4edJhk
  33:     0x7f126b2b0d00 - middle::trans::callee::trans_method_call::closure.115194
  34:     0x7f126b271930 - middle::trans::callee::trans_call_inner::h3d3ba09198f29bc9nR1
  35:     0x7f126b2b05a0 - middle::trans::callee::trans_method_call::h20b5c2a1e6f706d1BM1
  36:     0x7f126b2c5b40 - middle::trans::expr::trans_rvalue_dps_unadjusted::h68c42f27e53f341euG3
  37:     0x7f126b2610c0 - middle::trans::expr::trans_into::h02f395bc1df027d3QL2
  38:     0x7f126b2601f0 - middle::trans::controlflow::trans_stmt_semi::h4399908e9bfb4a53eMY
  39:     0x7f126b25ee40 - middle::trans::controlflow::trans_stmt::h814b238e9dbd031fXHY
  40:     0x7f126b2617e0 - middle::trans::controlflow::trans_block::h05731a7862534d438MY
  41:     0x7f126b3b30f0 - middle::trans::base::trans_closure::h761f159ac0f5b1d5Zve
  42:     0x7f126b24a4a0 - middle::trans::base::trans_fn::h7f652b8e491f5fceNIe
  43:     0x7f126b246590 - middle::trans::base::trans_item::h9c3deb60b9a1469bO1e
  44:     0x7f126b3c0b10 - middle::trans::base::trans_mod::hdc94d62cb0c66b22X5e
  45:     0x7f126b3d3920 - middle::trans::base::trans_crate::h2bbe93d38696f05f2Wf
  46:     0x7f126bc77620 - driver::driver::phase_4_translate_to_llvm::closure.136750
  47:     0x7f126bc76fc0 - util::common::time::h4601779646530965728
  48:     0x7f126bbb8380 - driver::driver::phase_4_translate_to_llvm::hcbbe57487cf47912Y1z
  49:     0x7f126bbb2860 - driver::driver::compile_input::hd5ac6510c8591e16pEz
  50:     0x7f126bcbc170 - driver::run_compiler::hfb28193ee56e89e2jcD
  51:     0x7f126bcbc040 - driver::main_args::closure.137687
  52:     0x7f126bcee7f0 - task::TaskBuilder<S>::try_future::closure.138848
  53:     0x7f126bcee3a0 - task::TaskBuilder<S>::spawn_internal::closure.138825
  54:     0x7f126a715d90 - task::spawn_opts::closure.8331
  55:     0x7f126a2ec3a0 - unwind::try::try_fn::__rust_abi
  56:     0x7f126a2ebdd0 - unwind::try::try_fn::hd559f7a319afd50b38d
  57:     0x7f126a3a63d0 - rust_try_inner
  58:     0x7f126a3a63c0 - rust_try
  59:     0x7f126a2e6250 - unwind::try::ha1bfe3bb2c20efd2F6d
  60:     0x7f126a2e5d50 - task::Task::run::hd76056204f6bfc11Zcd
  61:     0x7f126a7159c0 - task::spawn_opts::closure.8277
  62:     0x7f126a2ea4f0 - thread::thread_start::__rust_abi
  63:     0x7f126a2ea4e0 - thread::thread_start::hc1291c833034ff64LBd
  64:     0x7f1264b53fe0 - start_thread
  65:     0x7f1269fa0019 - __clone
  66:                0x0 - <unknown>

(This has my modifications to give a marginally more useful error message.)

The failure happens when looking up a type parameter DefId when handling the ty_param case.

What I actually get building html5ever is a failure of the preceding assertion regarding crate IDs. I didn't find a small reproducer for that assertion failure, but this bug is likely to be related.

@huonw
Copy link
Member

huonw commented Aug 25, 2014

cc me

@huonw
Copy link
Member

huonw commented Aug 25, 2014

(Slightly) simpler example:

// euv_ice.rs
#![crate_type="lib"]

pub struct TreeBuilder<H>;

impl<H> Iterator<H> for TreeBuilder<H> {
    fn next(&mut self) -> Option<H> { None }
}

impl<H> TreeBuilder<H> {
    pub fn process_token(&mut self) {
        match self {
            _ => for _y in *self {},
        }
    }
}
extern crate euv_ice;

fn main() {
    euv_ice::TreeBuilder::<uint>.process_token();
}

This appears to be related to AST being inlined cross-crate, and the for internals (cc @pcwalton) since desugaring it to the equivalent loop { match self.next() { doesn't ICE. It also requires that process_token is a method, a freestanding function stops the ICE.

@kmcallister
Copy link
Contributor Author

Cool, for now I'll go with the workaround of desugaring the for loop myself.

kmcallister added a commit to servo/html5ever that referenced this issue Aug 25, 2014
bors added a commit that referenced this issue Aug 26, 2014
We shouldn't be making calls directly to `ty::node_id_to_type` since the typer may be bcx which also has to monomorphize the type.

Fixes #16643.
@huonw huonw mentioned this issue Aug 28, 2014
kmcallister added a commit to servo/html5ever that referenced this issue Sep 3, 2014
kmcallister added a commit to servo/html5ever that referenced this issue Sep 4, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 25, 2024
internal: Optimize salsa memory usage

Reduces memory on self by ~20mb for me, there is a few more mb to save here if we made LRU caching opt-in, as currently every entry in a memoized query will store an `AtomicUsize` for the LRU.
bors pushed a commit to rust-lang-ci/rust that referenced this issue Feb 25, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 25, 2024
…643, r=Veykril

internal: fix deadlock introduced by rust-lang#16643

This fixes a deadlock introduced by rust-lang#16643 ([backtrace](https://gist.github.com/davidbarsky/00f17598f5496a9c41aff31fec1c42d6)). `maybe_changed_after` calls back into other queries, so the cloning here is unfortunately inevitable.

(Zulip conversation: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Fixing.20proc-macro.20dirtying.20with.20unindexed.20projects)
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) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants