Skip to content

ICE: 'index out of bounds: the len is 10 but the index is 10', src/libcollections/vec.rs:1395 #40000

Closed
@farcaller

Description

@farcaller

Rustc crashes on code that uses phf and discord crates.

I tried this code:

Cargo.toml:

[dependencies]
phf = {}
discord = { git = "https://github.com/SpaceManiac/discord-rs", default-features = false }

[build-dependencies]
phf_codegen = {}

(I was unable to reproduce this without discord crate so far)

main.rs:

extern crate phf;
extern crate discord;

use discord::Discord;
use discord::model::Message;

type Handler = fn(&Discord, Message) -> ();

fn hello(d: &Discord, m: Message) {
    println!("hello {:?}", m);
}

include!(concat!(env!("OUT_DIR"), "/codegen.rs"));

fn main() {
    println!("Hello, world!");
}

build.rs:

extern crate phf_codegen;

use std::env;
use std::fs::File;
use std::io::{BufWriter, Write};
use std::path::Path;

fn main() {
    let path = Path::new(&env::var("OUT_DIR").unwrap()).join("codegen.rs");
    let mut file = BufWriter::new(File::create(&path).unwrap());

    write!(&mut file,
           "static KEYWORDS: phf::Map<&'static str, Handler> = ")
        .unwrap();
    phf_codegen::Map::new()
        .entry("help", "hello as fn(_, _)")
        .build(&mut file)
        .unwrap();
    write!(&mut file, ";\n").unwrap();
}

I expected to see this happen: cargo build works

Instead, this happened:

% RUST_BACKTRACE=1 rustup run nightly cargo build --verbose
warning: dependency (phf) specified without providing a local path, Git repository, or version to use. This will be considered an error in future versions
warning: dependency (phf_codegen) specified without providing a local path, Git repository, or version to use. This will be considered an error in future versions
       Fresh httparse v1.2.1
       Fresh matches v0.1.4
       Fresh rustc-serialize v0.3.22
       Fresh byteorder v0.5.3
       Fresh dtoa v0.2.2
       Fresh semver v0.1.20
       Fresh pkg-config v0.3.9
       Fresh serde v0.8.23
       Fresh itoa v0.1.1
       Fresh bitflags v0.7.0
       Fresh unicode-normalization v0.1.4
       Fresh lazy_static v0.2.2
       Fresh cfg-if v0.1.0
       Fresh unicode-bidi v0.2.5
       Fresh num-traits v0.1.36
       Fresh traitobject v0.0.1
       Fresh log v0.3.6
       Fresh base64-rs v0.1.1
       Fresh language-tags v0.2.2
       Fresh gcc v0.3.43
       Fresh idna v0.1.0
       Fresh serde_json v0.8.6
       Fresh typeable v0.1.2
       Fresh mime v0.2.2
       Fresh hpack v0.2.0
       Fresh rustc_version v0.1.7
       Fresh url v1.4.0
       Fresh siphasher v0.2.1
       Fresh solicit v0.4.4
       Fresh libc v0.2.20
       Fresh num_cpus v1.2.1
       Fresh openssl-sys v0.7.17
       Fresh rand v0.3.15
       Fresh time v0.1.36
       Fresh net2 v0.2.26
       Fresh openssl-sys-extras v0.7.14
       Fresh tempdir v0.3.5
       Fresh miniz-sys v0.1.9
       Fresh openssl v0.7.14
       Fresh unicase v1.4.0
       Fresh flate2 v0.2.17
       Fresh cookie v0.2.5
       Fresh openssl-verify v0.1.0
       Fresh phf_shared v0.7.21
       Fresh hyper v0.9.18
       Fresh phf_generator v0.7.21
       Fresh phf v0.7.21
       Fresh websocket v0.17.1
       Fresh phf_codegen v0.7.21
       Fresh mime_guess v1.8.1
       Fresh multipart v0.8.1
       Fresh discord v0.7.0 (https://github.com/SpaceManiac/discord-rs#91e278a8)
   Compiling rust_ice v0.1.0 (file:///Users/farcaller/temp/a/rust_ice)
     Running `rustc --crate-name rust_ice src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=89aaf70fe57d6f66 -C extra-filename=-89aaf70fe57d6f66 --out-dir /Users/farcaller/temp/a/rust_ice/target/debug/deps -L dependency=/Users/farcaller/temp/a/rust_ice/target/debug/deps --extern phf=/Users/farcaller/temp/a/rust_ice/target/debug/deps/libphf-35cac82784b6858b.rlib --extern discord=/Users/farcaller/temp/a/rust_ice/target/debug/deps/libdiscord-86893f8fe920ef49.rlib -L native=/Users/farcaller/temp/a/rust_ice/target/debug/build/openssl-1d3ea894fa03cc5a/out -L native=/Users/farcaller/.homebrew/Cellar/openssl/1.0.2j/lib/ -L native=/Users/farcaller/temp/a/rust_ice/target/debug/build/openssl-sys-extras-8e2dc543f8892677/out -L native=/Users/farcaller/temp/a/rust_ice/target/debug/build/miniz-sys-18005000ddedadf4/out`
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 10 but the index is 10', src/libcollections/vec.rs:1395
stack backtrace:
   1:        0x112c8a1e9 - std::sys::imp::backtrace::tracing::imp::write::h9559bd7cb15d72ad
   2:        0x112c96c9e - std::panicking::default_hook::{{closure}}::h4b3f2b69c9ce844d
   3:        0x112c968cb - std::panicking::default_hook::h61d415f2381a7336
   4:        0x112c97117 - std::panicking::rust_panic_with_hook::h8e6300d8e8aca457
   5:        0x112c96fb4 - std::panicking::begin_panic::h08622fbe5a379aac
   6:        0x112c96f22 - std::panicking::begin_panic_fmt::ha00d3aa9db91f578
   7:        0x112c96e87 - rust_begin_unwind
   8:        0x112cd2870 - core::panicking::panic_fmt::h58d018e87f211baf
   9:        0x112cd27e8 - core::panicking::panic_bounds_check::h38556703686d76f6
  10:        0x10f0b70f5 - rustc::infer::region_inference::RegionVarBindings::var_origin::h1a3230bfe8f6b7a3
  11:        0x10f0a4dc4 - rustc::infer::error_reporting::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::note_issue_32330::hb0f6df70b0f976cf
  12:        0x10f0a5456 - rustc::infer::error_reporting::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::report_and_explain_type_error::hc9e8d67ad9240b5a
  13:        0x10f0d31f3 - rustc::infer::InferCtxt::report_mismatched_types::hcf3dfbb9f7da91e6
  14:        0x10e4cad72 - rustc_typeck::check::demand::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::demand_coerce::haabcfcf402883c15
  15:        0x10e5151d5 - rustc_typeck::check::check_const_with_type::hf3217b0c761ce445
  16:        0x10e50f44f - rustc_typeck::check::check_item_type::h21e704aeed7a2ebf
  17:        0x10e50882f - <rustc_typeck::check::CheckItemTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item::h548713d1fe126ca8
  18:        0x10e50ac23 - rustc_typeck::check::check_item_types::h561f2f5197c895cd
  19:        0x10e575a78 - rustc_typeck::check_crate::ha4804fc81adafb37
  20:        0x10dc848ec - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::ha6edf852b5e78329
  21:        0x10dbec6ac - rustc::ty::context::TyCtxt::create_and_enter::h7c59cfc34c012022
  22:        0x10dc5f09e - rustc_driver::driver::compile_input::hd50a6918443232a0
  23:        0x10dca321e - rustc_driver::run_compiler::h5151bfc01962b066
  24:        0x10dbb8938 - std::panicking::try::do_call::h9e86b95d9c931e3d
  25:        0x112c99d6a - __rust_maybe_catch_panic
  26:        0x10dbe1353 - <F as alloc::boxed::FnBox<A>>::call_box::ha55b035dd9316cf5
  27:        0x112c95dc4 - std::sys::imp::thread::Thread::new::thread_start::h80e9dc7cc1dfe0d2
  28:     0x7fffd1c99aaa - _pthread_body
  29:     0x7fffd1c999f6 - _pthread_start

error: Could not compile `rust_ice`.

Caused by:
  process didn't exit successfully: `rustc --crate-name rust_ice src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=89aaf70fe57d6f66 -C extra-filename=-89aaf70fe57d6f66 --out-dir /Users/farcaller/temp/a/rust_ice/target/debug/deps -L dependency=/Users/farcaller/temp/a/rust_ice/target/debug/deps --extern phf=/Users/farcaller/temp/a/rust_ice/target/debug/deps/libphf-35cac82784b6858b.rlib --extern discord=/Users/farcaller/temp/a/rust_ice/target/debug/deps/libdiscord-86893f8fe920ef49.rlib -L native=/Users/farcaller/temp/a/rust_ice/target/debug/build/openssl-1d3ea894fa03cc5a/out -L native=/Users/farcaller/.homebrew/Cellar/openssl/1.0.2j/lib/ -L native=/Users/farcaller/temp/a/rust_ice/target/debug/build/openssl-sys-extras-8e2dc543f8892677/out -L native=/Users/farcaller/temp/a/rust_ice/target/debug/build/miniz-sys-18005000ddedadf4/out` (exit code: 101)

Meta

rustc --version --verbose:

rustc 1.17.0-nightly (a17e5e2 2017-02-20)
binary: rustc
commit-hash: a17e5e2
commit-date: 2017-02-20
host: x86_64-apple-darwin
release: 1.17.0-nightly
LLVM version: 3.9

Metadata

Metadata

Assignees

Labels

I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions