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 with 'index out of bounds: the len is 0 but the index is 0' in librustc/middle/typeck/check/mod.rs:2678 #19521

Closed
ghost opened this issue Dec 4, 2014 · 0 comments · Fixed by #19638
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@ghost
Copy link

ghost commented Dec 4, 2014

I tried to compile code I was working on, which by my mistake tried to call a return value of non-existing function and I got ICE.

Source:

fn main() { [].does_not_exist()(); }

Result:

panic.rs:1:16: 1:32 error: type `[_, ..0]` does not implement any method in scope named `does_not_exist`
panic.rs:1 fn main() { [].does_not_exist()(); }
                          ^~~~~~~~~~~~~~~~
error: internal compiler error: unexpected panic
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
task 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /var/tmp/portage/dev-lang/rust-9999-r3/work/rust-9999/src/librustc/middle/typeck/check/mod.rs:2678

stack backtrace:
   1:     0x7f180c132d80 - rt::backtrace::imp::write::h15f1e1185148ff93edy
   2:     0x7f180c136710 - <unknown>
   3:     0x7f180bd8b030 - unwind::begin_unwind_inner::hc3ee95128eea69a66Qc
   4:     0x7f180bd8ac60 - unwind::begin_unwind_fmt::hb6fad94cf11ea4ddhOc
   5:     0x7f180bd8ac20 - rust_begin_unwind
   6:     0x7f180bdcf3b0 - panicking::panic_fmt::ha146387686ab12ffVXl
   7:     0x7f180bdd4860 - panicking::panic_bounds_check::hcac6d3b2fdf550f7tWl
   8:     0x7f180ae45f30 - <unknown>
   9:     0x7f180ae3d1d0 - <unknown>
  10:     0x7f180ae3a810 - <unknown>
  11:     0x7f180ae47620 - <unknown>
  12:     0x7f180ae7d8b0 - middle::typeck::check::check_stmt::hf7f81a4c86de5c59F2q
  13:     0x7f180ae00400 - <unknown>
  14:     0x7f180addae50 - <unknown>
  15:     0x7f180adfe050 - <unknown>
  16:     0x7f180adfa3c0 - middle::typeck::check::check_item::h5b28fa70b2217219WGl
  17:     0x7f180adfdd10 - middle::typeck::check::check_item_types::h5528955bf9d6bfd1Vll
  18:     0x7f180b164cb0 - <unknown>
  19:     0x7f180b163f10 - middle::typeck::check_crate::h09babae4dc71701dc6O
  20:     0x7f180c71bf70 - driver::driver::phase_3_run_analysis_passes::h23f258b8bc6b16397nS
  21:     0x7f180c7115c0 - driver::driver::compile_input::h3389418cf360d9f174R
  22:     0x7f180c799890 - <unknown>
  23:     0x7f180c799780 - <unknown>
  24:     0x7f180c5c3e90 - <unknown>
  25:     0x7f180c103200 - <unknown>
  26:     0x7f180bd88de0 - <unknown>
  27:     0x7f180bde2080 - <unknown>
  28:     0x7f180bde2070 - rust_try
  29:     0x7f180bd88ec0 - unwind::try::h0b27bbf3de71e33fpFc
  30:     0x7f180bd88c50 - task::Task::run::h3e1f1ea7d681f88efOb
  31:     0x7f180bd88840 - <unknown>
  32:     0x7f180bd8a2d0 - <unknown>
  33:     0x7f1807534250 - <unknown>
  34:     0x7f180ba68409 - __clone
  35:                0x0 - <unknown>

My rust version:
rustc 0.13.0-dev (3c89031 2014-12-04 04:52:37 +0000)
binary: rustc
commit-hash: 3c89031
commit-date: 2014-12-04 04:52:37 +0000
host: x86_64-unknown-linux-gnu
release: 0.13.0-dev

Backtrace from gdb:

(gdb) break rust_panic
Function "rust_panic" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (rust_panic) pending.
(gdb) run panic.rs
Starting program: /usr/bin/rustc panic.rs
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff03ff480 (LWP 30664)]
panic.rs:1:16: 1:32 error: type `[_, ..0]` does not implement any method in scope named `does_not_exist`
panic.rs:1 fn main() { [].does_not_exist()(); }
                          ^~~~~~~~~~~~~~~~
[Switching to Thread 0x7ffff03ff480 (LWP 30664)]

Breakpoint 1, 0x00007ffff70bba80 in rust_panic () from /usr/lib/rust-9999/librustrt-gentoo-git.so
(gdb) bt
#0  0x00007ffff70bba80 in rust_panic () from /usr/lib/rust-9999/librustrt-gentoo-git.so
#1  0x00007ffff70bc194 in unwind::begin_unwind_inner::hc3ee95128eea69a66Qc () from /usr/lib/rust-9999/librustrt-gentoo-git.so
#2  0x00007ffff70bbf0d in unwind::begin_unwind_fmt::hb6fad94cf11ea4ddhOc () from /usr/lib/rust-9999/librustrt-gentoo-git.so
#3  0x00007ffff70bbc60 in rust_begin_unwind () from /usr/lib/rust-9999/librustrt-gentoo-git.so
#4  0x00007ffff71003e9 in panicking::panic_fmt::ha146387686ab12ffVXl () from /usr/lib/rust-9999/librustrt-gentoo-git.so
#5  0x00007ffff71058fc in panicking::panic_bounds_check::hcac6d3b2fdf550f7tWl () from /usr/lib/rust-9999/librustrt-gentoo-git.so
#6  0x00007ffff6177ed0 in middle::typeck::check::check_argument_types::hca7f8145d403d642Myo () from /usr/lib/rust-9999/librustc-gentoo-git.so
#7  0x00007ffff616e292 in middle::typeck::check::check_method_argument_types::h64c1e1e9ccd7993eVwo () from /usr/lib/rust-9999/librustc-gentoo-git.so
#8  0x00007ffff616bd30 in middle::typeck::check::try_overloaded_call::hbc7d47c610f9542fj5n () from /usr/lib/rust-9999/librustc-gentoo-git.so
#9  0x00007ffff6178cf7 in middle::typeck::check::check_expr_with_unifier::ha2ce889b7659beabh7o () from /usr/lib/rust-9999/librustc-gentoo-git.so
#10 0x00007ffff61aeaa7 in middle::typeck::check::check_stmt::hf7f81a4c86de5c59F2q () from /usr/lib/rust-9999/librustc-gentoo-git.so
#11 0x00007ffff6131523 in middle::typeck::check::check_block_with_expected::ha736faeb540ea329U6q () from /usr/lib/rust-9999/librustc-gentoo-git.so
#12 0x00007ffff610cf30 in middle::typeck::check::check_fn::hb2691541cbe76f81Hxl () from /usr/lib/rust-9999/librustc-gentoo-git.so
#13 0x00007ffff612f186 in middle::typeck::check::check_bare_fn::h3413c0267a7f62a5Lml () from /usr/lib/rust-9999/librustc-gentoo-git.so
#14 0x00007ffff612b501 in middle::typeck::check::check_item::h5b28fa70b2217219WGl () from /usr/lib/rust-9999/librustc-gentoo-git.so
#15 0x00007ffff612eee1 in middle::typeck::check::check_item_types::h5528955bf9d6bfd1Vll () from /usr/lib/rust-9999/librustc-gentoo-git.so
#16 0x00007ffff6495d26 in util::common::time::h13439858745680149165 () from /usr/lib/rust-9999/librustc-gentoo-git.so
#17 0x00007ffff649512f in middle::typeck::check_crate::h09babae4dc71701dc6O () from /usr/lib/rust-9999/librustc-gentoo-git.so
#18 0x00007ffff7a4f58b in driver::driver::phase_3_run_analysis_passes::h23f258b8bc6b16397nS () from /usr/lib/rust-9999/librustc_trans-gentoo-git.so
#19 0x00007ffff7a44440 in driver::driver::compile_input::h3389418cf360d9f174R () from /usr/lib/rust-9999/librustc_trans-gentoo-git.so
#20 0x00007ffff7acc3f6 in driver::run_compiler::h59934d7af0b42919n3T () from /usr/lib/rust-9999/librustc_trans-gentoo-git.so
#21 0x00007ffff7aca7bc in driver::run::closure.59905 () from /usr/lib/rust-9999/librustc_trans-gentoo-git.so
#22 0x00007ffff78f4edb in task::TaskBuilder::try_future::closure.39678 () from /usr/lib/rust-9999/librustc_trans-gentoo-git.so
#23 0x00007ffff7434360 in task::TaskBuilder::spawn_internal::closure.30963 () from /usr/lib/rust-9999/libstd-gentoo-git.so
#24 0x00007ffff70b9e52 in task::Task::spawn::closure.5759 () from /usr/lib/rust-9999/librustrt-gentoo-git.so
#25 0x00007ffff711308c in rust_try_inner () from /usr/lib/rust-9999/librustrt-gentoo-git.so
#26 0x00007ffff7113076 in rust_try () from /usr/lib/rust-9999/librustrt-gentoo-git.so
#27 0x00007ffff70b9f03 in unwind::try::h0b27bbf3de71e33fpFc () from /usr/lib/rust-9999/librustrt-gentoo-git.so
#28 0x00007ffff70b9ccc in task::Task::run::h3e1f1ea7d681f88efOb () from /usr/lib/rust-9999/librustrt-gentoo-git.so
#29 0x00007ffff70b9918 in task::Task::spawn::closure.5735 () from /usr/lib/rust-9999/librustrt-gentoo-git.so
#30 0x00007ffff70bb355 in thread::thread_start::h9e312a11c305a77ai6b () from /usr/lib/rust-9999/librustrt-gentoo-git.so
#31 0x00007ffff2865314 in start_thread (arg=0x7ffff03ff480) at pthread_create.c:310
#32 0x00007ffff6d9943d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
@huonw huonw added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Dec 6, 2014
barosl added a commit to barosl/rust that referenced this issue Dec 10, 2014
When a type error occurs, check_method_argument_types() tries to provide
arguments filled with ty::mk_err(). However, if a function takes the
parameters as a tuple, the arguments should be converted to a tuple
before being passed to check_argument_types().

Fixes rust-lang#19521.
bors added a commit that referenced this issue Dec 10, 2014
When a type error occurs, `check_method_argument_types()` tries to provide arguments filled with `ty::mk_err()`. However, if a function takes the parameters as a tuple, the arguments should be converted to a tuple before passing it to `check_argument_types()`.

Fixes #19521.
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

Successfully merging a pull request may close this issue.

1 participant