Skip to content

ICE when compiling bad code #20683

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

Closed
spacejam opened this issue Jan 7, 2015 · 3 comments
Closed

ICE when compiling bad code #20683

spacejam opened this issue Jan 7, 2015 · 3 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@spacejam
Copy link

spacejam commented Jan 7, 2015

My code is certainly broken, but it triggered an ICE. Apologies if this is a duplicate! If the triggering code is useful, I've pushed a branch with the triggering material: https://github.com/spacejam/rust-rocksdb/tree/tan_ICE

rustc 0.13.0-nightly (c7dd3c4d6 2015-01-05 23:51:00 +0000)
binary: rustc
commit-hash: c7dd3c4d69aee1c4ad8cc220c194b176bba2ab62
commit-date: 2015-01-05 23:51:00 +0000
host: x86_64-apple-darwin
release: 0.13.0-nightly

...

   Compiling rocksdb v0.0.2 (file:///Users/tan/code/rust-rocksdb)
     Running `rustc /Users/tan/code/rust-rocksdb/src/lib.rs --crate-name rocksdb --crate-type lib -g -C metadata=6653d8e8924e4f84 -C extra-filename=-6653d8e8924e4f84 --out-dir /Users/tan/code/rust-rocksdb/target --emit=dep-info,link -L /Users/tan/code/rust-rocksdb/target -L /Users/tan/code/rust-rocksdb/target/deps`
/Users/tan/code/rust-rocksdb/src/rocksdb.rs:592:1: 621:2 error: internal compiler error: impl `VtableImpl(impl_def_id=DefId { krate: 0, node: 3108 }:rocksdb::&'a mut MergeOperands<'a>.Iterator, substs=Substs[types=[[];[];[]], regions=[['_#0r];[];[]]], nested=[[];[];[]])` did not contain projection for `Obligation(predicate=<&'a mut rocksdb::MergeOperands<'a> as TraitRef(&'a mut rocksdb::MergeOperands<'a>, core::iter::Iterator)>::Item,depth=0)`
/Users/tan/code/rust-rocksdb/src/rocksdb.rs:592 impl<'a> Iterator for &'a mut MergeOperands<'a> {
/Users/tan/code/rust-rocksdb/src/rocksdb.rs:593     fn next(&mut self) -> Option<&'a [u8]> {
/Users/tan/code/rust-rocksdb/src/rocksdb.rs:594         use std::raw::Slice;
/Users/tan/code/rust-rocksdb/src/rocksdb.rs:595         match self.cursor == self.num_operands {
/Users/tan/code/rust-rocksdb/src/rocksdb.rs:596             true => None,
/Users/tan/code/rust-rocksdb/src/rocksdb.rs:597             false => {
                                                ...
note: the compiler unexpectedly panicked. 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
thread 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:123

stack backtrace:
   1:        0x106f7d5e5 - sys::backtrace::write::h98e4664f4f31dc8eiTs
   2:        0x106fa2f4f - failure::on_fail::h15cffea110d6009eKVy
   3:        0x106f0840a - rt::unwind::begin_unwind_inner::h9de529c6f705175fKDy
   4:        0x104c09dc7 - rt::unwind::begin_unwind::h8742058877264024887
   5:        0x104c09d5c - diagnostic::SpanHandler::span_bug::h3bc28b7b3bcff0610kF
   6:        0x1043a1603 - middle::traits::project::project_type::h5ce8ef2558d93d50zQP
   7:        0x10439cb5e - middle::traits::project::opt_normalize_projection_type::hcee84b18f83e8d45CIP
   8:        0x10438ae43 - middle::traits::project::normalize_projection_type::h7c69afde591a893ddHP
   9:        0x10439df9f - middle::traits::project::AssociatedTypeNormalizer<'a, 'b, 'tcx>.TypeFolder<'tcx>::fold_ty::hc4b6ba01061942daOFP
  10:        0x103cab937 - middle::ty_fold::TypeFolder::fold_trait_ref::h6518936090498913440
  11:        0x103cac3a1 - middle::ty_fold::VecPerParamSpace<T>.TypeFoldable<'tcx>::fold_with::h10053445313753109854
  12:        0x103cc73b4 - check::FnCtxt<'a, 'tcx>::instantiate_bounds::h31abbc782f1f47fd1kl
  13:        0x103cdfdfd - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>::with_fcx::h1819609048976829711
  14:        0x103ce2620 - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>.Visitor<'v>::visit_item::h2bf7c5e628314514tki
  15:        0x103ce546f - visit::walk_mod::h14492313709251987009
  16:        0x103ce2fac - check::wf::CheckTypeWellFormedVisitor<'ccx, 'tcx>.Visitor<'v>::visit_item::h2bf7c5e628314514tki
  17:        0x103de546b - check_crate::unboxed_closure.39887
  18:        0x103de0d53 - check_crate::hbc0ab8570a19149famx
  19:        0x103711292 - driver::phase_3_run_analysis_passes::h61da41ec58961d9bSva
  20:        0x1036fdcac - driver::compile_input::h6ba151de4af50ce2vba
  21:        0x1037c0c13 - thunk::F.Invoke<A, R>::invoke::h15890902738341362910
  22:        0x1037bdd70 - rt::unwind::try::try_fn::h15939753852117214544
  23:        0x107008009 - rust_try_inner
  24:        0x107007ff6 - rust_try
  25:        0x1037be4b6 - thunk::F.Invoke<A, R>::invoke::h14011449182044061502
  26:        0x106f8ea34 - sys::thread::thread_start::h4e93ea2350249d53kGv
  27:     0x7fff8dcfa2fc - _pthread_body
  28:     0x7fff8dcfa279 - _pthread_body

Could not compile `rocksdb`.

Caused by:
  Process didn't exit successfully: `rustc /Users/tan/code/rust-rocksdb/src/lib.rs --crate-name rocksdb --crate-type lib -g -C metadata=6653d8e8924e4f84 -C extra-filename=-6653d8e8924e4f84 --out-dir /Users/tan/code/rust-rocksdb/target --emit=dep-info,link -L /Users/tan/code/rust-rocksdb/target -L /Users/tan/code/rust-rocksdb/target/deps` (status=101)
@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 7, 2015
@steveklabnik
Copy link
Member

Thanks! Yes, every ICE is a bug, regardless of the quality of code that makes it ICE. I don't think this is a dup.

@huonw
Copy link
Member

huonw commented Jan 7, 2015

This is a dupe of #20347. The fix is to write the type Item = ...; part of implementations of Iterator. That is, impl Iterator<X> for ... { becomes impl Iterator for ... { type Item = X;.

Thanks for filing!

(BTW, tangentially, you can't pass unboxed closures as f: FnMut(). The Fn* names are traits and should either be used as trait object, f: &mut FnMut(T) -> U or as generics: fn map<U, F: FnMut(T) -> U>(self, f: F). Also, since you're only calling the closures once, FnOnce will give slightly more flexibility.)

@huonw huonw closed this as completed Jan 7, 2015
@spacejam
Copy link
Author

spacejam commented Jan 7, 2015

@huonw awesome, thanks for the help! 😃

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

No branches or pull requests

3 participants