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

Compiler panic: 'index out of bounds' #24819

Closed
gsingh93 opened this issue Apr 25, 2015 · 5 comments
Closed

Compiler panic: 'index out of bounds' #24819

gsingh93 opened this issue Apr 25, 2015 · 5 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@gsingh93
Copy link
Contributor

Playpen link: http://is.gd/LITiE8
Example:

use std::collections::HashSet;

fn main() {
    let mut v = Vec::new();
    foo(&mut v);
}

fn foo(h: &mut HashSet<u32>) {
}

Output from playpen:

<anon>:5:9: 5:15 error: mismatched types:
 expected `&mut std::collections::hash::set::HashSet<u32>`,
    found `&mut collections::vec::Vec<_>`
(expected struct `std::collections::hash::set::HashSet`,
    found struct `collections::vec::Vec`) [E0308]
<anon>:5     foo(&mut v);
                 ^~~~~~
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
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'index out of bounds: the len is 3 but the index is 3', /home/rustbuild/src/rust-buildbot/slave/beta-dist-rustc-linux/build/src/libcollections/vec.rs:1358


playpen: application terminated with error code 101
Program ended.

Happens for me on rustc 1.1.0-nightly (f9e53c7f2 2015-04-24) (built 2015-04-25), and playpen is using beta, so it happens on that as well.

@nagisa
Copy link
Member

nagisa commented Apr 26, 2015

Duplicate of #23583. I’d close the linked issue, though, because this one has minimal example.


stack backtrace:
   1:     0x7f458a441e69 - sys::backtrace::write::h928094d59f02e42euYr
   2:     0x7f458a449c66 - panicking::on_panic::h63ff4dcb77cfcfd8iow
   3:     0x7f458a40bbe2 - rt::unwind::begin_unwind_inner::hdb381b8543316733s3v
   4:     0x7f458a40c9a7 - rt::unwind::begin_unwind_fmt::hcf17bc68f9d21adby2v
   5:     0x7f458a449846 - rust_begin_unwind
   6:     0x7f458a495e84 - panicking::panic_fmt::hfe7d5ac25990b130yKy
   7:     0x7f458a4a020c - panicking::panic_bounds_check::h215216d6195ef019EJy
   8:     0x7f4588512d2e - middle::infer::freshen::TypeFreshener<'a, 'tcx>.TypeFolder<'tcx>::fold_ty::h5b268b4226c40e95sQw
   9:     0x7f45885140d9 - middle::ty_fold::TypeFolder::fold_substs::h11516006423260476848
  10:     0x7f458858653c - middle::traits::select::SelectionContext<'cx, 'tcx>::select::hcb3cbfe0f063ffbcLYP
  11:     0x7f4588583cf5 - middle::traits::fulfill::FulfillmentContext<'tcx>::select::h212762fc4b72bb85WQN
  12:     0x7f458858333b - middle::traits::fulfill::FulfillmentContext<'tcx>::select_where_possible::h90e9b9b285e1bde0aQN
  13:     0x7f4589b9ee48 - check::vtable::select_fcx_obligations_where_possible::h8046b67f72f03a23I0b
  14:     0x7f4589b9ea2a - check::vtable::select_all_fcx_obligations_and_apply_defaults::h91d8c9ca8d40e7ab7Wb
  15:     0x7f4589c2bdd4 - check::check_bare_fn::h56950a2b577630famUn
  16:     0x7f4589c29f22 - check::CheckItemBodiesVisitor<'a, 'tcx>.Visitor<'tcx>::visit_item::h6380ca56bad0b447pRn
  17:     0x7f4589ceadaa - check_crate::closure.38501
  18:     0x7f4589ce6140 - check_crate::h3d2be1a2f2b833642EC
  19:     0x7f458a984798 - driver::phase_3_run_analysis_passes::hb4a5c5398e7ee860tGa
  20:     0x7f458a965e90 - driver::compile_input::h3635371ed416578cQba
  21:     0x7f458aa235d1 - run_compiler::hc7ca7ffdda3bac71F4b
  22:     0x7f458aa20e22 - boxed::F.FnBox<A>::call_box::h3375003542065736186
  23:     0x7f458aa203d9 - rt::unwind::try::try_fn::h12589008938305638456
  24:     0x7f458a4bd588 - rust_try_inner
  25:     0x7f458a4bd575 - rust_try
  26:     0x7f458aa20680 - boxed::F.FnBox<A>::call_box::h9305475706708510069
  27:     0x7f458a448a01 - sys::thread::Thread::new::thread_start::hde1d5c4c7d7f250fT9u
  28:     0x7f4584537373 - start_thread
  29:     0x7f458a0a027c - clone
  30:                0x0 - <unknown>

@Aatch Aatch added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Apr 28, 2015
@jirutka
Copy link

jirutka commented May 17, 2015

I ran into the same error when trying to compile datetime 0.1.7 with the current nightly.

$ RUST_BACKTRACE=1 cargo build
   Compiling datetime v0.1.7
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
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'index out of bounds: the len is 60 but the index is 117', /private/tmp/rust20150518-72266-n7gtuc/src/libcollections/vec.rs:1361

stack backtrace:
   1:        0x10fe31aef - sys::backtrace::write::ha44b3f4df72d371c32r
   2:        0x10fe3a5d0 - panicking::on_panic::h19b50da5ca5e05bauiw
   3:        0x10fdf5945 - rt::unwind::begin_unwind_inner::h0b7205538a0ab840d0v
   4:        0x10fdf674c - rt::unwind::begin_unwind_fmt::h88d3334f8dd63530jZv
   5:        0x10fe3a12c - rust_begin_unwind
   6:        0x10fe8c815 - panicking::panic_fmt::h41ecfe1a10526c59r3B
   7:        0x10fe876a8 - panicking::panic_bounds_check::h1e29ed4cc92cd76ax2B
   8:        0x116649805 - parse::token::get_name::h35e7e5fccea6e44dnZT
   9:        0x116742ef4 - parse::parser::Parser<'a>::lit_from_token::hf58c8962037cb225ZzH
  10:        0x116747f47 - parse::parser::Parser<'a>::parse_lit::h2e50eafa1ebd61ddZDH
  11:        0x116750023 - parse::parser::Parser<'a>::parse_bottom_expr::h9e9a850fefa543e4i9H
  12:        0x116755682 - parse::parser::Parser<'a>::parse_dot_or_call_expr::h05b5aa9a18a416d2iCI
  13:        0x116759c99 - parse::parser::Parser<'a>::parse_prefix_expr::hcdeb32d1451049bax5I
  14:        0x11675a412 - parse::parser::Parser<'a>::parse_binops::he3e0fd996016893ekeJ
  15:        0x11675aee5 - parse::parser::Parser<'a>::parse_assign_expr::h53209e75bf3e1361ckJ
  16:        0x116723861 - parse::parser::Parser<'a>::parse_expr::h9c3b3a2e323926e41RF
  17:        0x11155937e - parse::h2eeaa28acf5ad6604Se
  18:        0x111558b5e - native::h055b9d86463f67cc2aa
  19:        0x114856c43 - ext::base::F.TTMacroExpander::expand::h16589758004100754197
  20:        0x10f75aed8 - ext::expand::expand_expr::closure.66525
  21:        0x10f7586c0 - ext::expand::expand_expr::h205e82f220007a1f9Lb
  22:        0x10f761470 - fold::noop_fold_expr::h15685179544264607782
  23:        0x10f758d1b - ext::expand::expand_expr::closure.66525
  24:        0x10f7586c0 - ext::expand::expand_expr::h205e82f220007a1f9Lb
  25:        0x10f761cb4 - fold::noop_fold_expr::h15685179544264607782
  26:        0x10f758d1b - ext::expand::expand_expr::closure.66525
  27:        0x10f7586c0 - ext::expand::expand_expr::h205e82f220007a1f9Lb
  28:        0x10f7a6557 - ext::expand::expand_block_elts::closure.67187
  29:        0x10f76c359 - ext::expand::expand_block_elts::h1415cb18ccd320f2Mxc
  30:        0x10f7a6172 - ext::expand::expand_block::h7d5c060d19c0744c7wc
  31:        0x10f76bdc1 - ext::expand::expand_and_rename_fn_decl_and_block::h4a7a8fe955c244cab1c
  32:        0x10f7724aa - ext::expand::expand_item_underscore::h264c173708ffb055hbc
  33:        0x10f7c611c - fold::noop_fold_item_simple::h15088194635162742853
  34:        0x10f7c5efe - ptr::P<T>::map::h2926393362253440021
  35:        0x10f770491 - ext::expand::expand_annotatable::hbcf3d8c020636cdb8Hc
  36:        0x10f76c4d9 - ext::expand::expand_item::h4a790b6e8b59cdb7Gac
  37:        0x10f777602 - iter::FlatMap<I, U, F>.Iterator::next::h7298186205452440470
  38:        0x10f777235 - vec::Vec<T>.FromIterator<T>::from_iter::h2720693747523327938
  39:        0x10f772cf6 - ext::expand::expand_item_underscore::h264c173708ffb055hbc
  40:        0x10f7c611c - fold::noop_fold_item_simple::h15088194635162742853
  41:        0x10f7c5efe - ptr::P<T>::map::h2926393362253440021
  42:        0x10f771487 - ext::expand::expand_annotatable::hbcf3d8c020636cdb8Hc
  43:        0x10f76c4d9 - ext::expand::expand_item::h4a790b6e8b59cdb7Gac
  44:        0x10f777602 - iter::FlatMap<I, U, F>.Iterator::next::h7298186205452440470
  45:        0x10f777235 - vec::Vec<T>.FromIterator<T>::from_iter::h2720693747523327938
  46:        0x10f772cf6 - ext::expand::expand_item_underscore::h264c173708ffb055hbc
  47:        0x10f7c611c - fold::noop_fold_item_simple::h15088194635162742853
  48:        0x10f7c5efe - ptr::P<T>::map::h2926393362253440021
  49:        0x10f771487 - ext::expand::expand_annotatable::hbcf3d8c020636cdb8Hc
  50:        0x10f76c4d9 - ext::expand::expand_item::h4a790b6e8b59cdb7Gac
  51:        0x10f7cda05 - ext::expand::expand_crate::hb3a4d686dfcac529E9c
  52:        0x10c91d5d5 - driver::phase_2_configure_and_expand::closure.20416
  53:        0x10c8d00ae - driver::phase_2_configure_and_expand::h6e78b7cbbae1e1ccYsa
  54:        0x10c8c0369 - driver::compile_input::hd0ddbf75d3cab180Qba
  55:        0x10c97cf63 - run_compiler::hc7fc80763a6a7ff875b
  56:        0x10c97a6ca - boxed::F.FnBox<A>::call_box::h10164488635330116687
  57:        0x10c979c27 - rt::unwind::try::try_fn::h2426084354629403706
  58:        0x10fec0458 - rust_try_inner
  59:        0x10fec0445 - rust_try
  60:        0x10c979efd - boxed::F.FnBox<A>::call_box::h15095568843964241812
  61:        0x10fe391bd - sys::thread::Thread::new::thread_start::h6ac7556a78cca2c6Hlv
  62:     0x7fff94422898 - _pthread_body
  63:     0x7fff94422729 - _pthread_start

rustc 1.2.0-nightly (8b7c17d 2015-05-17) (built 2015-05-18)
OS X 10.9.5

@arielb1
Copy link
Contributor

arielb1 commented Jun 15, 2015

@jirutka

Different error.

arielb1 pushed a commit to arielb1/rust that referenced this issue Jun 15, 2015
This adds transaction support to fulfill. I can't use it in rust-lang#26282
because that would require nested transactions.

This doesn't seem to cause compilation time to regress.

Fixes rust-lang#24819.
@evadnoob
Copy link

evadnoob commented Jul 1, 2015

I get this same error, right after I added serde_macros to my Cargo.toml.

❯ RUST_BACKTRACE=1 cargo build                                                                                                                                                                                                                                         [32/4241]
   Compiling serde_codegen v0.4.2
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 'index out of bounds: the len is 92 but the index is 529', ../src/libcollections/vec.rs:1362

stack backtrace:
   1:        0x10a1ae485 - sys::backtrace::write::ha69861d01c280e10Vns
   2:        0x10a1b6be3 - panicking::on_panic::he1db6e7d5ec9c9022Fw
   3:        0x10a172af2 - rt::unwind::begin_unwind_inner::h9f73b873795fcd2deow
   4:        0x10a173849 - rt::unwind::begin_unwind_fmt::h3999b4670fb43708knw
   5:        0x10a1b676c - rust_begin_unwind
   6:        0x10a20ae35 - panicking::panic_fmt::he89ea3094b3178e919B
   7:        0x10a2055b5 - panicking::panic_bounds_check::h8058af339f14343278B
   8:        0x10f375347 - util::interner::StrInterner::get::h33e23c9881d31a76Fpa
   9:        0x10ba9b224 - parse::token::get_name::hc8e6f23ae3b0497cwaT
  10:        0x10ba9b398 - parse::token::get_ident::h623c49ac14f4e12cNaT
  11:        0x10ba9b34c - str::ast..Ident.ToInternedString::to_interned_string::h226749af2201972apgd
  12:        0x10ba464b4 - lit::LitBuilder<F>::str::h2287811883313644798
  13:        0x10ba463f5 - expr::ExprBuilder<F>::str::h15103756226570193947
  14:        0x10ba46143 - mk_ident::h76e644649ecee0d6Yia
  15:        0x10ba4edb7 - expr_mk_token::h530e0aaf1ac4f9c2Cla
  16:        0x10ba53578 - statements_mk_tt::ha8ed870f505b201bBAa
  17:        0x10ba5bf8e - statements_mk_tt::closure.5782
  18:        0x10ba5bf1d - iter::FlatMap<I, U, F>.Iterator::next::closure.5777
  19:        0x10ba5be7d - option::Option<T>::map::h992756666428157757
  20:        0x10ba5bc0d - iter::FlatMap<I, U, F>.Iterator::next::h16461546956636534358
  21:        0x10ba5b9bd - iter::Chain<A, B>.Iterator::next::h15790673721037698405
  22:        0x10ba5b8a1 - iter::Chain<A, B>.Iterator::next::h13883406854348817918
  23:        0x10ba5cf34 - vec::Vec<T>::extend_desugared::h14308067113245803033
  24:        0x10ba5b561 - vec::Vec<T>.FromIterator<T>::from_iter::h4567733303014666736
  25:        0x10ba5b0db - iter::Iterator::collect::h15870988852878513640
  26:        0x10ba5449f - statements_mk_tt::ha8ed870f505b201bBAa
  27:        0x10ba4071d - statements_mk_tts::hf5a22e049c2a847cZJa
  28:        0x10ba228c2 - expand_tts::h4a76f356700220c2QKa
  29:        0x10ba3bacb - expand_parse_call::h847fdc0375aa33afHMa
  30:        0x10ba3cc23 - expand_quote_expr::hb1131b5a4ef58447Oba
  31:        0x10edf4bbe - ext::base::F.TTMacroExpander::expand::h16772666232880655435
  32:        0x107c39e8b - ext::expand::expand_expr::closure.64675
  33:        0x107c35510 - ext::expand::expand_expr::h99495f0a4050bb0eO3a
  34:        0x107c8e7de - ext::expand::expand_block_elts::closure.65395
  35:        0x107c8cb3e - ext::expand::expand_block_elts::closure.65376
  36:        0x107c48b8a - ext::expand::expand_block_elts::hae5d90e0cb6f3badrPb
  37:        0x107c8c552 - ext::expand::expand_block::h19a07d5850d44ec3MOb
  38:        0x107c3eb93 - fold::noop_fold_expr::h13944231768787436517
  39:        0x107c35712 - ext::expand::expand_expr::closure.64675
  40:        0x107c35510 - ext::expand::expand_expr::h99495f0a4050bb0eO3a
  41:        0x107c88130 - ext::expand::expand_arm::h362881c67b77a2bf5Jb
  42:        0x107c3e7d7 - fold::noop_fold_expr::h13944231768787436517
  43:        0x107c35712 - ext::expand::expand_expr::closure.64675
  44:        0x107c35510 - ext::expand::expand_expr::h99495f0a4050bb0eO3a
  45:        0x107c8e7de - ext::expand::expand_block_elts::closure.65395
  46:        0x107c8cb3e - ext::expand::expand_block_elts::closure.65376
  47:        0x107c48b8a - ext::expand::expand_block_elts::hae5d90e0cb6f3badrPb
  48:        0x107c8c552 - ext::expand::expand_block::h19a07d5850d44ec3MOb
  49:        0x107c4855c - ext::expand::expand_and_rename_fn_decl_and_block::h2f6d7bbfc095110aQic
  50:        0x107cb4677 - ext::expand::expand_and_rename_method::h146aa2e4f3025329akc
  51:        0x107cb963d - ext::expand::expand_impl_item::closure.65794
  52:        0x107cb5f05 - ext::expand::expand_impl_item::h624cadcd858560f3zfc
  53:        0x107c4c2ea - ext::expand::expand_annotatable::hd1384fdfcaa7365bNZb
  54:        0x107c5b91f - ext::expand::MacroExpander<'a, 'b>.Folder::fold_impl_item::h3c6c8bcc8f2aea45Gnc
  55:        0x107c5b39c - iter::FlatMap<I, U, F>.Iterator::next::h2176610863638934878
  56:        0x107c5b6c6 - vec::Vec<T>::extend_desugared::h3745718402942750841
  57:        0x107c5a3d7 - iter::Iterator::collect::h15651229304304986698
  58:        0x107c50e93 - ext::expand::expand_item_underscore::hc68401b64125c559Vsb
  59:        0x107cb3744 - fold::Folder::fold_item_simple::h6115586095879100014
  60:        0x107cb3313 - ptr::P<T>::map::h8648109792104747851
  61:        0x107c4cfcd - ext::expand::expand_annotatable::hd1384fdfcaa7365bNZb
  62:        0x107c48d11 - ext::expand::expand_item::h544d5c924b5556adksb
  63:        0x107c55c0a - iter::FlatMap<I, U, F>.Iterator::next::h10402144123647243192
  64:        0x107c54b17 - vec::Vec<T>.FromIterator<T>::from_iter::h2531848258214199605
  65:        0x107c542df - fold::noop_fold_mod::h11533148739362704925
  66:        0x107c5028e - ext::expand::expand_item_underscore::hc68401b64125c559Vsb
  67:        0x107cb3744 - fold::Folder::fold_item_simple::h6115586095879100014
  68:        0x107cb3313 - ptr::P<T>::map::h8648109792104747851
  69:        0x107c4da4d - ext::expand::expand_annotatable::hd1384fdfcaa7365bNZb
  70:        0x107c48d11 - ext::expand::expand_item::h544d5c924b5556adksb
  71:        0x107c612e4 - iter::FlatMap<I, U, F>.Iterator::next::h4604195285113091658
  72:        0x107c60357 - util::small_vector::SmallVector<T>.FromIterator<T>::from_iter::h15534074357520757775
  73:        0x107c5f1fb - ext::expand::expand_item_mac::h42d76a4eac0c1d4bmvb
  74:        0x107c4c9d7 - ext::expand::expand_annotatable::hd1384fdfcaa7365bNZb
  75:        0x107c48d11 - ext::expand::expand_item::h544d5c924b5556adksb
  76:        0x107c55c0a - iter::FlatMap<I, U, F>.Iterator::next::h10402144123647243192
  77:        0x107c54b17 - vec::Vec<T>.FromIterator<T>::from_iter::h2531848258214199605
  78:        0x107c542df - fold::noop_fold_mod::h11533148739362704925
  79:        0x107c5028e - ext::expand::expand_item_underscore::hc68401b64125c559Vsb
  80:        0x107cb3744 - fold::Folder::fold_item_simple::h6115586095879100014
  81:        0x107cb3313 - ptr::P<T>::map::h8648109792104747851
  82:        0x107c4da4d - ext::expand::expand_annotatable::hd1384fdfcaa7365bNZb
  83:        0x107c48d11 - ext::expand::expand_item::h544d5c924b5556adksb
  84:        0x107cbc9ef - ext::expand::expand_crate::he8ff7220990af98elrc
  85:        0x106693aa2 - driver::phase_2_configure_and_expand::closure.21445
  86:        0x106648bd2 - driver::phase_2_configure_and_expand::h154d7c2f9d5ff029ita
  87:        0x10663844d - driver::compile_input::hb76410fc800a2a41Tba
  88:        0x1067123af - run_compiler::hd724b5fef3441688y7b
  89:        0x10670fc63 - boxed::F.FnBox<A>::call_box::h16633087113713113418
  90:        0x10670f427 - rt::unwind::try::try_fn::h14742554275296927735
  91:        0x10a2430f8 - rust_try_inner
  92:        0x10a2430e5 - rust_try
  93:        0x10a1a09a5 - rt::unwind::try::inner_try::h2041d75ee62fcacd7jw
  94:        0x10670f658 - boxed::F.FnBox<A>::call_box::h11995599304104652074
  95:        0x10a1b566d - sys::thread::Thread::new::thread_start::hb06fec4578e7b89frIv
  96:     0x7fff95ccd2fb - _pthread_body
  97:     0x7fff95ccd278 - _pthread_start

arielb1 pushed a commit to arielb1/rust that referenced this issue May 24, 2016
Refactor `FnCtxt::autoderef` to use an external iterator and to not
register any obligation from the main autoderef loop, but rather to
register them after (and if) the loop successfully completes.

Fixes rust-lang#24819
Fixes rust-lang#25801
Fixes rust-lang#27631
Fixes rust-lang#31258
Fixes rust-lang#31964
Fixes rust-lang#32320
Fixes rust-lang#33515
Fixes rust-lang#33755
@apasel422
Copy link
Contributor

Is this the same issue as #31964?

Manishearth added a commit to Manishearth/rust that referenced this issue May 28, 2016
refactor autoderef to avoid prematurely registering obligations

Refactor `FnCtxt::autoderef` to use an external iterator and to not
register any obligation from the main autoderef loop, but rather to
register them after (and if) the loop successfully completes.

Fixes rust-lang#24819
Fixes rust-lang#25801
Fixes rust-lang#27631
Fixes rust-lang#31258
Fixes rust-lang#31964
Fixes rust-lang#32320
Fixes rust-lang#33515
Fixes rust-lang#33755

r? @eddyb
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

7 participants