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' #31258

Closed
Antiarchitect opened this issue Jan 28, 2016 · 0 comments
Closed

Compiler panic 'index out of bounds' #31258

Antiarchitect opened this issue Jan 28, 2016 · 0 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Antiarchitect
Copy link

I tried this to compile:

pub fn load(external_id: &String) -> Vec<u8> {
    let map_store_path = construct_store_path(&MAPS_PATH.to_string(), external_id);
    let map_path = construct_storable_path(&map_store_path, external_id);
    let map_file = fs::File::open(&map_path);
    let mut map_bytes = Vec::new();
    try!(map_file.read_to_end(&map_bytes));
    let map = json::decode(&map_bytes).unwrap();

    vec![0]
}

This is what happened:

cargo build --verbose
       Fresh regex-syntax v0.2.2
       Fresh libc v0.1.12
       Fresh rustc-serialize v0.3.16
       Fresh winapi-build v0.1.1
       Fresh gcc v0.3.21
       Fresh winapi v0.2.5
       Fresh libc v0.2.5
       Fresh strsim v0.3.0
       Fresh memchr v0.1.7
       Fresh aho-corasick v0.4.0
       Fresh advapi32-sys v0.1.2
       Fresh regex v0.1.48
       Fresh rand v0.3.13
       Fresh kernel32-sys v0.2.1
       Fresh docopt v0.6.78
       Fresh uuid v0.1.18
       Fresh time v0.1.34
       Fresh rust-crypto v0.2.34
   Compiling rusty-vault v0.1.0 (file:///home/andrey/PROJECTS/rusty-vault)
     Running `rustc src/lib.rs --crate-name rusty_vault --crate-type lib -g --out-dir /home/andrey/PROJECTS/rusty-vault/target/debug --emit=dep-info,link -L dependency=/home/andrey/PROJECTS/rusty-vault/target/debug -L dependency=/home/andrey/PROJECTS/rusty-vault/target/debug/deps --extern uuid=/home/andrey/PROJECTS/rusty-vault/target/debug/deps/libuuid-fed17b74aa7673e2.rlib --extern rustc_serialize=/home/andrey/PROJECTS/rusty-vault/target/debug/deps/librustc_serialize-3c33cb2a40992011.rlib --extern docopt=/home/andrey/PROJECTS/rusty-vault/target/debug/deps/libdocopt-eb02b06dca39e75f.rlib --extern crypto=/home/andrey/PROJECTS/rusty-vault/target/debug/deps/libcrypto-daa20c09deb34369.rlib --extern rand=/home/andrey/PROJECTS/rusty-vault/target/debug/deps/librand-340832a8942cb900.rlib -L native=/home/andrey/PROJECTS/rusty-vault/target/debug/build/rust-crypto-daa20c09deb34369/out`
src/lib.rs:95:19: 95:42 error: no method named `read_to_end` found for type `core::result::Result<std::fs::File, std::io::error::Error>` in the current scope
src/lib.rs:95     try!(map_file.read_to_end(&map_bytes));
                                ^~~~~~~~~~~~~~~~~~~~~~~
src/lib.rs:95:5: 95:44 note: in this expansion of try! (defined in <std macros>)
<std macros>:5:8: 6:42 error: mismatched types:
 expected `collections::vec::Vec<u8>`,
    found `core::result::Result<_, _>`
(expected struct `collections::vec::Vec`,
    found enum `core::result::Result`) [E0308]
<std macros>:5 return $ crate:: result:: Result:: Err (
<std macros>:6 $ crate:: convert:: From:: from ( err ) ) } } )
src/lib.rs:95:5: 95:44 note: in this expansion of try! (defined in <std macros>)
<std macros>:5:8: 6:42 help: run `rustc --explain E0308` to see a detailed explanation
src/lib.rs:96:28: 96:38 error: mismatched types:
 expected `&str`,
    found `&collections::vec::Vec<_>`
(expected str,
    found struct `collections::vec::Vec`) [E0308]
src/lib.rs:96     let map = json::decode(&map_bytes).unwrap();
                                         ^~~~~~~~~~
src/lib.rs:96:28: 96:38 help: run `rustc --explain E0308` to see a detailed explanation
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 41 but the index is 43', ../src/libcollections/vec.rs:1132
stack backtrace:
   1:     0x7f9f14f35bf0 - sys::backtrace::tracing::imp::write::haa19c02b4de52f3bG0t
   2:     0x7f9f14f3c7d5 - panicking::log_panic::_<closure>::closure.41218
   3:     0x7f9f14f3c26f - panicking::log_panic::h527fe484e9de8fe1W7x
   4:     0x7f9f14f058c3 - sys_common::unwind::begin_unwind_inner::h51f64b1a34c60827fTs
   5:     0x7f9f14f06228 - sys_common::unwind::begin_unwind_fmt::h0845853a1913f45blSs
   6:     0x7f9f14f33a41 - rust_begin_unwind
   7:     0x7f9f14f844ff - panicking::panic_fmt::h3967afc085fe8067LFK
   8:     0x7f9f14f846e2 - panicking::panic_bounds_check::h3ef0001c29fc27faREK
   9:     0x7f9f12931fba - middle::infer::freshen::_<impl>::fold_ty::h385c5e4b6e47b7b2DTA
  10:     0x7f9f1293301a - middle::ty::fold::TypeFolder::fold_substs::h9623948748133425890
  11:     0x7f9f1288edab - middle::traits::select::_<impl>::select::h72d9651b4643fb4ek9V
  12:     0x7f9f1299a699 - middle::traits::fulfill::process_predicate::h1b5045a3d87829cbzxT
  13:     0x7f9f12999011 - middle::traits::fulfill::_<impl>::select::h72ea95d19c079f78lrT
  14:     0x7f9f12998b67 - middle::traits::fulfill::_<impl>::select_where_possible::hefc120b787239eacPpT
  15:     0x7f9f1302a929 - check::_<impl>::select_obligations_where_possible::h25ff65c70a796932hdr
  16:     0x7f9f13044416 - check::_<impl>::resolve_type_vars_if_possible::h70b6d1b4ea56d8a2ihq
  17:     0x7f9f130588ea - check::structurally_resolved_type::habb550ef2b21cf6fNLu
  18:     0x7f9f1306e139 - check::check_expr_with_unifier::check_method_call::hc6178cfb274295c2pfs
  19:     0x7f9f1307d23d - check::check_expr_with_unifier::h11438309499393148616
  20:     0x7f9f130a432d - check::check_decl_initializer::hba6d574e1579b6b5mvt
  21:     0x7f9f130a43c8 - check::check_decl_local::he10984636f0a7d09ywt
  22:     0x7f9f130a495f - check::check_stmt::hb85f5b931ade7374oyt
  23:     0x7f9f1303410f - check::check_block_with_expected::h941a3b8ddab8cb3elCt
  24:     0x7f9f13027913 - check::check_fn::h55a894fbba67c54a0np
  25:     0x7f9f13021f88 - check::check_bare_fn::hbaa926eb29147a7fpdp
  26:     0x7f9f1301ed85 - check::check_item_body::h8b0cc3f68dab1b260Cp
  27:     0x7f9f1301569e - check::check_item_bodies::h8cbb1440ac817150xbp
  28:     0x7f9f1300da5a - check_crate::h3c513ff74deef0a2jxD
  29:     0x7f9f1543bca8 - driver::phase_3_run_analysis_passes::_<closure>::closure.25599
  30:     0x7f9f1541f813 - middle::ty::context::_<impl>::create_and_enter::create_and_enter::h13716335538836217011
  31:     0x7f9f1541b251 - driver::phase_3_run_analysis_passes::h5249241190295309167
  32:     0x7f9f153f0559 - driver::compile_input::h58ee58653fb11a3ehca
  33:     0x7f9f153e277b - run_compiler::hd4933b7af1175e4aOwc
  34:     0x7f9f153df436 - sys_common::unwind::try::try_fn::try_fn::h5795434642313485966
  35:     0x7f9f14f33888 - __rust_try
  36:     0x7f9f14f2b18b - sys_common::unwind::try::inner_try::h771fec597ec8f35cNPs
  37:     0x7f9f153df790 - boxed::_<impl>::call_box::call_box::h18189923456789545281
  38:     0x7f9f14f3acd3 - sys::thread::_<impl>::new::thread_start::haf749b76474da6b089w
  39:     0x7f9f0ebd4609 - start_thread
  40:     0x7f9f14bc6a4c - clone
  41:                0x0 - <unknown>

Could not compile `rusty-vault`.

Caused by:
  Process didn't exit successfully: `rustc src/lib.rs --crate-name rusty_vault --crate-type lib -g --out-dir /home/andrey/PROJECTS/rusty-vault/target/debug --emit=dep-info,link -L dependency=/home/andrey/PROJECTS/rusty-vault/target/debug -L dependency=/home/andrey/PROJECTS/rusty-vault/target/debug/deps --extern uuid=/home/andrey/PROJECTS/rusty-vault/target/debug/deps/libuuid-fed17b74aa7673e2.rlib --extern rustc_serialize=/home/andrey/PROJECTS/rusty-vault/target/debug/deps/librustc_serialize-3c33cb2a40992011.rlib --extern docopt=/home/andrey/PROJECTS/rusty-vault/target/debug/deps/libdocopt-eb02b06dca39e75f.rlib --extern crypto=/home/andrey/PROJECTS/rusty-vault/target/debug/deps/libcrypto-daa20c09deb34369.rlib --extern rand=/home/andrey/PROJECTS/rusty-vault/target/debug/deps/librand-340832a8942cb900.rlib -L native=/home/andrey/PROJECTS/rusty-vault/target/debug/build/rust-crypto-daa20c09deb34369/out` (exit code: 101)

rustc 1.6.0 (c30b771ad 2016-01-19) binary: rustc commit-hash: c30b771ad9d44ab84f8c88b80c25fcfde2433126 commit-date: 2016-01-19 host: x86_64-unknown-linux-gnu release: 1.6.0

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 2, 2016
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
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

2 participants