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 - trying to take the sizing type of <core::iter::Iterator + 'static as core::iter::Iterator>::Item, an unsized type #20605

Closed
shepmaster opened this issue Jan 6, 2015 · 4 comments
Labels
A-associated-items Area: Associated items (types, constants & functions) A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@shepmaster
Copy link
Member

Code

fn changer<'a>(mut things: Box<Iterator<Item=&'a mut u8>>) {
    for item in *things { *item = 0 }
}

fn main() {
}

Error

error: internal compiler error: trying to take the sizing type of <core::iter::Iterator + 'static as core::iter::Iterator>::Item, an unsized type
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/shep/Projects/rust/src/libsyntax/diagnostic.rs:182

stack backtrace:
   1:        0x110a80d05 - sys::backtrace::write::h57cb71e45a6ad05bARs
   2:        0x110aa667f - failure::on_fail::h1e60313e5a552ea32Ty
   3:        0x110a0bb6a - rt::unwind::begin_unwind_inner::h591d6980cb1eb9bb2By
   4:        0x10e753937 - rt::unwind::begin_unwind::h15926596774839260564
   5:        0x10e7542a8 - diagnostic::Handler::bug::h4055c4ca2e17f0c6DLF
   6:        0x10dd63cb8 - session::Session::bug::h5d1941c792f1e4caroq
   7:        0x10d326a23 - trans::type_of::sizing_type_of::hded88082b54ddc4bgSo
   8:        0x10d4422eb - trans::adt::represent_type_uncached::h5d90b81a92acc1b47xH
   9:        0x10d320cd3 - trans::adt::represent_type::hdeb853742a302b7fHuH
  10:        0x10d30c662 - trans::type_of::type_of::h0a1f71fc9850898aYYo
  11:        0x10d30c34c - trans::type_of::type_of::h0a1f71fc9850898aYYo
  12:        0x10d3b803f - trans::type_of::type_of_rust_fn::hf6b24d412c4c9582xOo
  13:        0x10d41665c - trans::meth::trans_trait_callee_from_llval::h2aa4e324f7a786d6kwz
  14:        0x10d413a56 - trans::meth::trans_object_shim::hfa24eaa4bec56008jBz
  15:        0x10d31eb5f - trans::meth::trans_method_callee::hce96e8ac9be0c90eq6y
  16:        0x10d385573 - trans::callee::trans_call_inner::h12246188759747685167
  17:        0x10d354691 - trans::expr::trans_rvalue_stmt_unadjusted::hd58bf8791601bef4kQi
  18:        0x10d306c8d - trans::expr::trans_into::h8bab20af1840b0a57xh
  19:        0x10d307605 - trans::controlflow::trans_block::h051994b75eb2405cS1d
  20:        0x10d3d0f44 - trans::base::trans_closure::hb694bfd51133ec9fMSt
  21:        0x10d2f2a2b - trans::base::trans_fn::h816a9b6a32db67faj3t
  22:        0x10d2ee086 - trans::base::trans_item::h223cbaffa1a561c6aqu
  23:        0x10d3d8718 - trans::base::trans_crate::h7f75c26047f82847vlv
  24:        0x10d19064e - driver::phase_4_translate_to_llvm::h17f0f28873e0c2d6uFa
  25:        0x10d172501 - driver::compile_input::h059943f6c48c38c7vba
  26:        0x10d239173 - thunk::F.Invoke<A, R>::invoke::h17305763774885229909
  27:        0x10d2362d0 - rt::unwind::try::try_fn::h8419390306595151514
  28:        0x110b0dba9 - rust_try_inner
  29:        0x110b0db96 - rust_try
  30:        0x10d236a16 - thunk::F.Invoke<A, R>::invoke::h8115208835806211442
  31:        0x110a92154 - sys::thread::thread_start::hf32c2ee467ccc238CEv
  32:     0x7fff9663c2fc - _pthread_body
  33:     0x7fff9663c279 - _pthread_body

Version

rustc 0.13.0-dev (5773bdeff 2015-01-04 21:36:41 +0000)
binary: rustc
commit-hash: 5773bdefff2e47cc007f5cc2af3f80b30303d45a
commit-date: 2015-01-04 21:36:41 +0000
host: x86_64-apple-darwin
release: 0.13.0-dev
@kmcallister kmcallister added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-DSTs Area: Dynamically-sized types (DSTs) labels Jan 6, 2015
@Sgeo
Copy link
Contributor

Sgeo commented Jan 7, 2015

The following also ICEs on Rust playpen:

fn changer<'a>(things: &mut Iterator) {
    for item in *things {  }
}

fn main() {
}

@nikomatsakis nikomatsakis added the A-associated-items Area: Associated items (types, constants & functions) label Jan 11, 2015
@skurmedel
Copy link

I am getting this as well for a function:

fn write_ppm16(
    out: &mut Writer, 
    dims: (u16, u16), 
    pixels: &mut iter::Iterator<Item = RGB16>,
    opt_conf: Option<PPMConfig>) -> IoResult<u32> {
// ...
for p in *pixels {
        try!(out.write_be_u16(p.r));
        try!(out.write_be_u16(p.g));
        try!(out.write_be_u16(p.b));

        bytes_written += 6;
    }
// ...
}

Is there a work-around?

Error

error: internal compiler error: trying to take the sizing type of <core::iter::Iterator + 'static as core::iter::Iterator>::Item, an unsized type
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', C:\bot\slave\nightly-dist-rustc-win-64\build\src\libsyntax\diagnostic.rs:182

stack backtrace:
1: 0x69bee9cd - sys::backtrace::write::hd40c6de25ef01e0bfjt
2: 0x69c01a32 - rt::unwind::register::hcb202fda23aef97aw7y
3: 0x69b834a7 - rt::unwind::begin_unwind_inner::h43ca250f1ae88b3e64y
4: 0x6f89cbf6 - diagnostic::SpanHandler::span_bug::hb66e4bdba79bcb62uGF
5: 0x6f89d4a5 - diagnostic::Handler::bug::h85a78a072de1c70cuMF
6: 0x902ba2 - session::Session::bug::h67201db2df2c561edcq
7: 0x1184508 - trans::common::u32.AsU64::as_u64::hb09c0f9cedc2afe9Vml
8: 0x129bd66 - trans::adt::Struct<'tcx>...std..cmp..Eq::assert_receiver_is_total_eq::ha4043fc1c68313ebebH
9: 0x117deca - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_custom_cleanup_scope::he19b59ee6fbbbdabvoK
10: 0x11698b8 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::push_custom_cleanup_scope::h8a436d69fac4a20bveK
11: 0x1169588 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::push_custom_cleanup_scope::h8a436d69fac4a20bveK
12: 0x121591f - trans::context::CrateContext<'b, 'tcx>::report_overbig_object::h7fa55c84f4a7e14cxDm
13: 0x1272821 - trans::closure::ClosureKind<'tcx>...std..cmp..PartialEq::eq::h22627d35aff317eamOx
14: 0x126fb19 - trans::closure::ClosureKind<'tcx>...std..cmp..PartialEq::eq::h22627d35aff317eamOx
15: 0x117bda3 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_custom_cleanup_scope::he19b59ee6fbbbdabvoK
16: 0x11e43ca - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::schedule_free_value::h59b3033bcd53c94bkBK
17: 0x11b4b1b - trans::type_::Type...std..cmp..PartialEq::ne::hc5732761018813b3ckJ
18: 0x11644a6 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_ast_cleanup_scope::h001d1bfc7990d7c63hK
19: 0x116338b - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::push_ast_cleanup_scope::hb0e55269a2ff9d34l9J
20: 0x1164aef - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::pop_and_trans_ast_cleanup_scope::h001d1bfc7990d7c63hK
21: 0x122d3de - trans::base::IsUnboxedClosureFlag...std..clone..Clone::clone::h8d9b5221c757fe7fbLt
22: 0x114fea0 - trans::context::CrateContext<'b, 'tcx>::sess::h0c92734bae2bfb65wmm
23: 0x114b63d - trans::context::CrateContext<'b, 'tcx>::stats::hfdf50b198e5f7592qzm
24: 0x122fc48 - trans::cleanup::FunctionContext<'blk, 'tcx>.CleanupMethods<'blk, 'tcx>::push_custom_cleanup_scope_with_debug_loc::hc8a6918f1c87a4b9ngK
25: 0x114b857 - trans::context::CrateContext<'b, 'tcx>::stats::hfdf50b198e5f7592qzm
26: 0x1234728 - trans::base::trans_crate::ha9ad2d2ee040c191Udv
27: 0x70b2543a - driver::phase_4_translate_to_llvm::h9dcbc7c0b9c8c65bJFa
28: 0x70b03243 - driver::compile_input::h45b30318e07c4cf6vba
29: 0x70bcaa1e - run::heefafb1ff7869308B4b
30: 0x70bc786a - run::heefafb1ff7869308B4b
31: 0x69c288fc - rust_try
32: 0x69c288d9 - rust_try
33: 0x70bc7fa9 - run::heefafb1ff7869308B4b
34: 0x69bf3457 - sys::tcp::TcpListener::bind::hfcf283b88d14d24bfTv
35: 0x775659ed - BaseThreadInitThunk

Version

rustc 1.0.0-nightly (ea6f65c 2015-01-06 19:47:08 +0000)
binary: rustc
commit-hash: ea6f65c
commit-date: 2015-01-06 19:47:08 +0000
host: x86_64-pc-windows-gnu
release: 1.0.0-nightly

@japaric
Copy link
Member

japaric commented Jan 26, 2015

Updated error message is an LLVM assertion:

rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/IR/Instructions.cpp:550: void llvm::InvokeInst::init(llvm::Value*, llvm::BasicBlock*, llvm::BasicBlock*, llvm::ArrayRef<llvm::Value*>, const llvm::Twine&): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Invoking a function with a bad signature!"' failed.
[1]    8065 abort (core dumped)  rustc 20605.rs

To workaround the bug, simply don't dereference the iterator, this doesn't crash:

fn changer<'a>(mut things: Box<Iterator<Item=&'a mut u8>>) {
    for item in things { *item = 0 }
}

fn main() {
}

@japaric
Copy link
Member

japaric commented Jan 26, 2015

FWIW, the new for loops (#20790) report a compiler error in this case, instead of ICEing:

fn changer<'a>(mut things: Box<Iterator<Item=&'a mut u8>>) {
    for item in *things { *item = 0 }
}

fn main() {
}

Output:

20605.rs:2:5: 3:2 error: the trait `core::marker::Sized` is not implemented for the type `core::iter::Iterator` [E0277]
20605.rs:2     for item in *things { *item = 0 }
20605.rs:3 }
20605.rs:2:5: 3:2 note: `core::iter::Iterator` does not have a constant size known at compile-time
20605.rs:2     for item in *things { *item = 0 }
20605.rs:3 }
20605.rs:2:5: 3:2 error: the trait `core::marker::Sized` is not implemented for the type `core::iter::Iterator` [E0277]
20605.rs:2     for item in *things { *item = 0 }
20605.rs:3 }
20605.rs:2:5: 3:2 note: `core::iter::Iterator` does not have a constant size known at compile-time
20605.rs:2     for item in *things { *item = 0 }
20605.rs:3 }
20605.rs:2:5: 3:2 error: the trait `core::marker::Sized` is not implemented for the type `core::iter::Iterator` [E0277]
20605.rs:2     for item in *things { *item = 0 }
20605.rs:3 }
20605.rs:2:5: 3:2 note: `core::iter::Iterator` does not have a constant size known at compile-time
20605.rs:2     for item in *things { *item = 0 }
20605.rs:3 }
error: aborting due to 3 previous errors

cc @nikomatsakis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-DSTs Area: Dynamically-sized types (DSTs) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

6 participants