Skip to content

compiler panic: index out of bounds: the len is 6 but the index is 6 #19165

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

Closed
jgillich opened this issue Nov 21, 2014 · 3 comments
Closed

compiler panic: index out of bounds: the len is 6 but the index is 6 #19165

jgillich opened this issue Nov 21, 2014 · 3 comments

Comments

@jgillich
Copy link

[jakob@aspire hyper]$ RUST_BACKTRACE=1 cargo build
   Compiling hyper v0.0.1 (file:///home/jakob/devel/hyper)
<std macros>:3:24: 119:30 error: type `http::HttpWriter<std::io::buffered::BufferedWriter<Box<net::NetworkStream+Send>>>` cannot be dereferenced
<std macros>:3         let dst = &mut *$dst;
<std macros>:4         format_args!(|args| { dst.write_fmt(args) }, $($arg)*)
<std macros>:5     })
<std macros>:6 )
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 6 but the index is 6', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/libsyntax/lib.rs:1

stack backtrace:
   1:     0x7f86a65479c0 - rt::backtrace::imp::write::h7fe8534f465d0e09y9s
   2:     0x7f86a654ab60 - failure::on_fail::h3fe2ecde6aab0bb8rwt
   3:     0x7f86a6d07c80 - unwind::begin_unwind_inner::he6bc2073d4eb582enbd
   4:     0x7f86a6d07900 - unwind::begin_unwind_fmt::h305b4b28825355b2y8c
   5:     0x7f86a6d078c0 - rust_begin_unwind
   6:     0x7f86a6d4da70 - panicking::panic_fmt::h9d03fcf6b4c3f8e10Nl
   7:     0x7f86a6d52e60 - panicking::panic_bounds_check::h5c6357fea6530f04yMl
   8:     0x7f86a43bb130 - codemap::FileMap::get_line::h8bd7cfe56e6cfd5e1aF
   9:     0x7f86a43e99b0 - diagnostic::emit::h2322127ddc0c36debCG
  10:     0x7f86a43e63d0 - diagnostic::EmitterWriter.Emitter::emit::hb9a4d5c26c04e1df0xG
  11:     0x7f86a43e4c50 - diagnostic::Handler::emit::ha390aea82acc4940kfG
  12:     0x7f86a43b7910 - diagnostic::SpanHandler::span_err::h83b27707d23c7bfej3F
  13:     0x7f86a57b5720 - middle::typeck::infer::InferCtxt<'a, 'tcx>::type_error_message_str_with_expected::h72941615d6be270289E
  14:     0x7f86a56c1840 - middle::typeck::infer::InferCtxt<'a, 'tcx>::type_error_message::h3e78576a7aeba36csfF
  15:     0x7f86a56caf70 - middle::typeck::check::check_expr_with_unifier::h23742768f253d831DLl
  16:     0x7f86a56caf70 - middle::typeck::check::check_expr_with_unifier::h23742768f253d831DLl
  17:     0x7f86a573fc40 - middle::typeck::check::check_decl_local::h24893462a5fe4409xSn
  18:     0x7f86a573fe00 - middle::typeck::check::check_stmt::h1ca15bfe8a7d5a87xUn
  19:     0x7f86a5679d90 - middle::typeck::check::check_block_with_expected::heebc1a2b04a42760MYn
  20:     0x7f86a56caf70 - middle::typeck::check::check_expr_with_unifier::h23742768f253d831DLl
  21:     0x7f86a55f6100 - middle::typeck::check::_match::check_match::h2c871678897b201eeA8
  22:     0x7f86a56caf70 - middle::typeck::check::check_expr_with_unifier::h23742768f253d831DLl
  23:     0x7f86a5679d90 - middle::typeck::check::check_block_with_expected::heebc1a2b04a42760MYn
  24:     0x7f86a56caf70 - middle::typeck::check::check_expr_with_unifier::h23742768f253d831DLl
  25:     0x7f86a573fe00 - middle::typeck::check::check_stmt::h1ca15bfe8a7d5a87xUn
  26:     0x7f86a5679d90 - middle::typeck::check::check_block_with_expected::heebc1a2b04a42760MYn
  27:     0x7f86a5675810 - middle::typeck::check::check_fn::hd39b1b6b62f22c3fici
  28:     0x7f86a5675530 - middle::typeck::check::check_bare_fn::h779ff7b2db70ca5bn1h
  29:     0x7f86a567cda0 - middle::typeck::check::check_method_body::h6418d5a11969c3d7nwi
  30:     0x7f86a5671310 - middle::typeck::check::check_item::hde22067b8b575546vli
  31:     0x7f86a5674e60 - visit::walk_mod::h974639367282189498
  32:     0x7f86a5674e60 - visit::walk_mod::h974639367282189498
  33:     0x7f86a56751c0 - middle::typeck::check::check_item_types::h7118271db2ab8ea8x0h
  34:     0x7f86a5a61e10 - util::common::time::h4997555828079517418
  35:     0x7f86a5a61020 - middle::typeck::check_crate::h0949dffd97487b5ejVL
  36:     0x7f86a720ba10 - driver::driver::phase_3_run_analysis_passes::h7f3610cf195b4c3abfS
  37:     0x7f86a7200830 - driver::driver::compile_input::h13734d451479d6e7VVR
  38:     0x7f86a72857b0 - driver::run_compiler::h0a1cb9376c105f68pUT
  39:     0x7f86a72856a0 - driver::run::closure.59745
  40:     0x7f86a7091ee0 - task::TaskBuilder<S>::try_future::closure.39051
  41:     0x7f86a7091cd0 - task::TaskBuilder<S>::spawn_internal::closure.39022
  42:     0x7f86a75a5b90 - task::NativeSpawner.Spawner::spawn::closure.2472
  43:     0x7f86a6d604c0 - rust_try_inner
  44:     0x7f86a6d604b0 - rust_try
  45:     0x7f86a6d055e0 - unwind::try::h7c27f4e149aed3f2IZc
  46:     0x7f86a6d05470 - task::Task::run::h75863ac7ddab20c0y5b
  47:     0x7f86a75a58d0 - task::NativeSpawner.Spawner::spawn::closure.2398
  48:     0x7f86a6d06c90 - thread::thread_start::h7822af80b22f729bEqc
  49:     0x7f86a15d0460 - start_thread
  50:     0x7f86a69db749 - clone
  51:                0x0 - <unknown>

Could not compile `hyper`.
[jakob@aspire hyper]$ rustc --version=verbose
rustc 0.13.0-nightly (399ff259e 2014-11-20 00:27:07 +0000)
binary: rustc
commit-hash: 399ff259e18c1061aa4ea60856fcecb486d36624
commit-date: 2014-11-20 00:27:07 +0000
host: x86_64-unknown-linux-gnu
release: 0.13.0-nightly

To reproduce:

  1. Clone https://github.com/jgillich/hyper/tree/fmt
  2. cargo build
@ashleysommer
Copy link
Contributor

I came here to file literally the same issue. Coincidentally also compiling a (different) HTTP library.
Using latest Rust master.

RUST_BACKTRACE=1 cargo build --verbose
       Fresh encoding_index_tests v0.1.0 (http://github.com/lifthrasiir/rust-encoding#b1eee875)
       Fresh gcc v0.0.1 (https://github.com/alexcrichton/gcc-rs#f25b3ba9)
       Fresh encoding-index-tradchinese v1.0.20140915 (http://github.com/lifthrasiir/rust-encoding#b1eee875)
       Fresh encoding-index-korean v1.0.20140915 (http://github.com/lifthrasiir/rust-encoding#b1eee875)
       Fresh encoding-index-simpchinese v1.0.20140915 (http://github.com/lifthrasiir/rust-encoding#b1eee875)
       Fresh encoding-index-japanese v1.0.20140915 (http://github.com/lifthrasiir/rust-encoding#b1eee875)
       Fresh encoding-index-singlebyte v1.0.20140915 (http://github.com/lifthrasiir/rust-encoding#b1eee875)
       Fresh encoding v0.2.3 (http://github.com/lifthrasiir/rust-encoding#b1eee875)
       Fresh url v0.1.0 (https://github.com/servo/rust-url#5d15bee2)
       Fresh time v0.0.3 (https://github.com/rust-lang/time#9595d0bc)
   Compiling tiny_http v0.0.1 (file:///home/flubba86/ClionProjects/tiny-http(upload))
     Running `rustc /home/flubba86/ClionProjects/tiny-http(upload)/src/lib.rs --crate-name tiny_http --crate-type lib -g -C metadata=a4527134254ec2f4 -C extra-filename=-a4527134254ec2f4 --out-dir /home/flubba86/ClionProjects/tiny-http(upload)/target --dep-info /home/flubba86/ClionProjects/tiny-http(upload)/target/.fingerprint/tiny_http-a4527134254ec2f4/dep-lib-tiny_http -L /home/flubba86/ClionProjects/tiny-http(upload)/target -L /home/flubba86/ClionProjects/tiny-http(upload)/target/deps --extern encoding=/home/flubba86/ClionProjects/tiny-http(upload)/target/deps/libencoding-83b8e0a6e831c6fe.rlib --extern url=/home/flubba86/ClionProjects/tiny-http(upload)/target/deps/liburl-921578b148f50e06.rlib --extern time=/home/flubba86/ClionProjects/tiny-http(upload)/target/deps/libtime-d924131696e54b12.rlib -L /home/flubba86/ClionProjects/tiny-http(upload)/target/build/time-d924131696e54b12/out`
<std macros>:3:24: 74:23 error: type `W` cannot be dereferenced
<std macros>:3         let dst = &mut *$dst;
<std macros>:4         format_args!(|args| { dst.write_fmt(args) }, $($arg)*)
<std macros>:5     })
<std macros>:6 )
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 6 but the index is 6', /home/flubba86/ClionProjects/rust1/src/libsyntax/lib.rs:1

stack backtrace:
   1:     0x7f5ee82db4b0 - rt::backtrace::imp::write::h8a405cfd8c4396c8B9s
   2:     0x7f5ee82ddf80 - failure::on_fail::h25e4014ba8bd0150uwt
   3:     0x7f5ee9030590 - unwind::begin_unwind_inner::h036f42082d648fc6nbd
   4:     0x7f5ee902fed0 - unwind::begin_unwind_fmt::h63d6194988bc700ey8c
   5:     0x7f5ee902fe60 - unwind::rust_begin_unwind::__rust_abi
   6:     0x7f5ee902fe00 - rust_begin_unwind
   7:     0x7f5ee90b6600 - panicking::panic_fmt::h9b64d3d148d43babaOl
   8:     0x7f5ee90ca8f0 - panicking::panic_bounds_check::closure.24524
   9:     0x7f5ee90ca230 - panicking::panic_bounds_check::h8b09047c8e0d6de5IMl
  10:     0x7f5ee4dce220 - vec::Vec<T>.Index<uint, T>::index::h13296517075474870301
  11:     0x7f5ee4dce7d0 - codemap::FileMap::get_line::h968503406ea5c987m4E
  12:     0x7f5ee4e29a60 - diagnostic::highlight_lines::he212720ca7df7227mAG
  13:     0x7f5ee4e27320 - diagnostic::emit::h96f49ef21ff994c3wvG
  14:     0x7f5ee4e1e2a0 - diagnostic::EmitterWriter.Emitter::emit::hfc2b401a44e9fb57lrG
  15:     0x7f5ee4e1b170 - diagnostic::Handler::emit::h2c6717da6b5795acF8F
  16:     0x7f5ee4dc05b0 - diagnostic::SpanHandler::span_err::h2cae115528589b17EWF
  17:     0x7f5ee62db1c0 - session::Session::span_err::h1290354ba20547c8Rq1
  18:     0x7f5ee6dbefc0 - middle::typeck::infer::InferCtxt<'a, 'tcx>::type_error_message_str_with_expected::h0bb8f60cea19de07TKF
  19:     0x7f5ee6dbee90 - middle::typeck::infer::InferCtxt<'a, 'tcx>::type_error_message_str::hb7cef490efc13ee4aKF
  20:     0x7f5ee6b8d460 - middle::typeck::infer::InferCtxt<'a, 'tcx>::type_error_message::h2d3cc777e752438bdQF
  21:     0x7f5ee6a01df0 - middle::typeck::check::FnCtxt<'a, 'tcx>::type_error_message::ha6fb48c500670cb9jdl
  22:     0x7f5ee6bc2b10 - middle::typeck::check::check_expr_with_unifier::h0dbf737eb021cff9Nzm
  23:     0x7f5ee6bc9050 - middle::typeck::check::check_expr_with_expectation_and_lvalue_pref::h86dfcb5ca588d4a0Erm
  24:     0x7f5ee6bc2b10 - middle::typeck::check::check_expr_with_unifier::h0dbf737eb021cff9Nzm
  25:     0x7f5ee6bc1540 - middle::typeck::check::check_expr_coercable_to_type::h31b8b00ee254719cSpm
  26:     0x7f5ee6c2fe40 - middle::typeck::check::check_decl_initializer::h5bc40a7eb0aae7a9Kso
  27:     0x7f5ee6c2fec0 - middle::typeck::check::check_decl_local::h855c07b06be28625gto
  28:     0x7f5ee6c30200 - middle::typeck::check::check_stmt::h5ef35cdc4d9c47f5gvo
  29:     0x7f5ee6afe8d0 - middle::typeck::check::check_block_with_expected::hc777cdebc78f5772vzo
  30:     0x7f5ee6bc2b10 - middle::typeck::check::check_expr_with_unifier::h0dbf737eb021cff9Nzm
  31:     0x7f5ee68a5e20 - middle::typeck::check::check_expr_has_type::hdfc9e782e51d827dapm
  32:     0x7f5ee68a5ac0 - middle::typeck::check::_match::check_match::hfecd5ed6941017b05P8
  33:     0x7f5ee6bc2b10 - middle::typeck::check::check_expr_with_unifier::h0dbf737eb021cff9Nzm
  34:     0x7f5ee6b279f0 - middle::typeck::check::check_expr_with_expectation::hed9aa97cedf54cf27qm
  35:     0x7f5ee6afe8d0 - middle::typeck::check::check_block_with_expected::hc777cdebc78f5772vzo
  36:     0x7f5ee6bc2b10 - middle::typeck::check::check_expr_with_unifier::h0dbf737eb021cff9Nzm
  37:     0x7f5ee689f320 - middle::typeck::check::check_expr::hf8316221db8c619cfsm
  38:     0x7f5ee6c30200 - middle::typeck::check::check_stmt::h5ef35cdc4d9c47f5gvo
  39:     0x7f5ee6afe8d0 - middle::typeck::check::check_block_with_expected::hc777cdebc78f5772vzo
  40:     0x7f5ee6a8d8e0 - middle::typeck::check::check_fn::h04a0d7b2ed09a1cce0i
  41:     0x7f5ee6ae3770 - middle::typeck::check::check_bare_fn::h523bbaa22a732feejPi
  42:     0x7f5ee6adaee0 - middle::typeck::check::check_item::hd0b9ae388150a0a0t9i
  43:     0x7f5ee6adae80 - middle::typeck::check::CheckItemTypesVisitor<'a, 'tcx>.Visitor<'v>::visit_item::h4b78b00102611fa2WNi
  44:     0x7f5ee6ae1c60 - visit::walk_mod::h17267871328085943818
  45:     0x7f5ee6ae1c00 - visit::Visitor::visit_mod::h3243897094775644115
  46:     0x7f5ee6adc5d0 - visit::walk_item::h10656758597348061101
  47:     0x7f5ee6adae80 - middle::typeck::check::CheckItemTypesVisitor<'a, 'tcx>.Visitor<'v>::visit_item::h4b78b00102611fa2WNi
  48:     0x7f5ee6ae1c60 - visit::walk_mod::h17267871328085943818
  49:     0x7f5ee6ae1c00 - visit::Visitor::visit_mod::h3243897094775644115
  50:     0x7f5ee6ae3690 - visit::walk_crate::h17586396567340744879
  51:     0x7f5ee6ae2ed0 - middle::typeck::check::check_item_types::hed950dc88cf71222tOi
  52:     0x7f5ee72f1ad0 - middle::typeck::check_crate::closure.142588
  53:     0x7f5ee72ee9d0 - util::common::time::h10144082460099455207
  54:     0x7f5ee72ee6d0 - middle::typeck::check_crate::h7f14887da1f59c09cwM
  55:     0x7f5ee99267a0 - driver::driver::phase_3_run_analysis_passes::h8814e32378c6f9batfS
  56:     0x7f5ee991f860 - driver::driver::compile_input::hcd47e1ad54a22e70dWR
  57:     0x7f5ee9a539b0 - driver::run_compiler::hedc32aa9be3cae57HUT
  58:     0x7f5ee9a53870 - driver::run::closure.65110
  59:     0x7f5ee9486a00 - task::TaskBuilder<S>::try_future::closure.39355
  60:     0x7f5ee94864e0 - task::TaskBuilder<S>::spawn_internal::closure.39324
  61:     0x7f5ee9e9cd30 - task::NativeSpawner.Spawner::spawn::closure.2472
  62:     0x7f5ee902f7a0 - unwind::try::try_fn::__rust_abi
  63:     0x7f5ee902f300 - unwind::try::try_fn::haf1738b98ae171e8V1c
  64:     0x7f5ee90f2930 - rust_try_inner
  65:     0x7f5ee90f2920 - rust_try
  66:     0x7f5ee902a010 - unwind::try::h036278122fffae79IZc
  67:     0x7f5ee9029cf0 - task::Task::run::h99a74865c94ccad2y5b
  68:     0x7f5ee9e9c7f0 - task::NativeSpawner.Spawner::spawn::closure.2396
  69:     0x7f5ee902d7e0 - thread::start_thread::h01c702f00a03d242Spc
  70:     0x7f5ee902da10 - thread::thread_start::__rust_abi
  71:     0x7f5ee902d9f0 - thread::thread_start::h59f79b652abf5cd3Eqc
  72:     0x7f5ee89ecfe0 - start_thread
  73:     0x7f5ee8ce7c89 - __clone
  74:                0x0 - <unknown>

Could not compile `tiny_http`.

Caused by:
  Process didn't exit successfully: `rustc /home/flubba86/ClionProjects/tiny-http(upload)/src/lib.rs --crate-name tiny_http --crate-type lib -g -C metadata=a4527134254ec2f4 -C extra-filename=-a4527134254ec2f4 --out-dir /home/flubba86/ClionProjects/tiny-http(upload)/target --dep-info /home/flubba86/ClionProjects/tiny-http(upload)/target/.fingerprint/tiny_http-a4527134254ec2f4/dep-lib-tiny_http -L /home/flubba86/ClionProjects/tiny-http(upload)/target -L /home/flubba86/ClionProjects/tiny-http(upload)/target/deps --extern encoding=/home/flubba86/ClionProjects/tiny-http(upload)/target/deps/libencoding-83b8e0a6e831c6fe.rlib --extern url=/home/flubba86/ClionProjects/tiny-http(upload)/target/deps/liburl-921578b148f50e06.rlib --extern time=/home/flubba86/ClionProjects/tiny-http(upload)/target/deps/libtime-d924131696e54b12.rlib -L /home/flubba86/ClionProjects/tiny-http(upload)/target/build/time-d924131696e54b12/out` (status=101)
rustc 0.13.0-dev (d13aff122 2014-11-20 19:26:40 +0000)
binary: rustc
commit-hash: d13aff12246ab3c72b0c5f186400a21f825c0a6c
commit-date: 2014-11-20 19:26:40 +0000
host: x86_64-unknown-linux-gnu
release: 0.13.0-dev

@ashleysommer
Copy link
Contributor

This is actually a duplicate of #19142 (I didn't search well enough when posting in this issue).

Basically, something calls write!(w, ..), the macro expands with an error in it (cannot dereference w), which throws out the number of lines in the macro, that causes the unwind panic.
That part is related to the old #14091 issue.

The fix is to do write!(&w, ...) in your code.

@huonw
Copy link
Member

huonw commented Nov 21, 2014

Closing as a dupe of #14091; thanks for filing!

@huonw huonw closed this as completed Nov 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants