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

rustc panicked at byte index 4 is out of bounds of #41652

Closed
messense opened this issue Apr 30, 2017 · 2 comments
Closed

rustc panicked at byte index 4 is out of bounds of #41652

messense opened this issue Apr 30, 2017 · 2 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@messense
Copy link
Contributor

I tried this code:

sozu-proxy/sozu#173

rustc --version --verbose:

rustc 1.19.0-nightly (afa1240e5 2017-04-29)
binary: rustc
commit-hash: afa1240e57330d85a372db4e28cd8bc8fa528ccb
commit-date: 2017-04-29
host: x86_64-apple-darwin
release: 1.19.0-nightly
LLVM version: 4.0

Backtrace:

   Compiling sozu-lib v0.2.0 (file:///Users/messense/Projects/sozu/lib)
error: no method named `deserialize` found for type `D` in the current scope
   --> lib/src/messages.rs:208:18
    |
208 |     deserializer.deserialize(OrderFieldVisitor)
    |                  ^^^^^^^^^^^
    |
    = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
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 'byte index 4 is out of bounds of ``', src/libcore/str/mod.rs:2162
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   5: std::panicking::begin_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::str::slice_error_fail
   9: rustc_errors::emitter::EmitterWriter::emit_message_default
  10: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit
  11: rustc_errors::diagnostic_builder::DiagnosticBuilder::emit
  12: rustc_typeck::check::method::suggest::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::report_method_error
  13: rustc_typeck::check::FnCtxt::check_expr_kind
  14: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  15: rustc_typeck::check::FnCtxt::check_block_with_expected::{{closure}}
  16: rustc_typeck::check::FnCtxt::check_block_with_expected
  17: rustc_typeck::check::FnCtxt::check_expr_kind
  18: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref
  19: rustc_typeck::check::FnCtxt::check_return_expr
  20: rustc_typeck::check::check_fn
  21: rustc_typeck::check::typeck_tables_of
  22: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  23: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  24: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
  25: rustc_typeck::check::typeck_item_bodies
  26: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get
  27: rustc::ty::maps::TyCtxtAt::typeck_item_bodies
  28: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_item_bodies
  29: rustc_typeck::check_crate
  30: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}
  31: rustc_driver::driver::phase_3_run_analysis_passes
  32: rustc_driver::driver::compile_input
  33: rustc_driver::run_compiler
  34: std::panicking::try::do_call
  35: __rust_maybe_catch_panic
  36: <F as alloc::boxed::FnBox<A>>::call_box
  37: std::sys::imp::thread::Thread::new::thread_start
  38: _pthread_body
  39: _pthread_start

error: Could not compile `sozu-lib`.

To learn more, run the command again with --verbose.
@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Apr 30, 2017
@kennytm
Copy link
Member

kennytm commented Apr 30, 2017

Reduced test case:

Crate a:

extern crate b;
struct S;
impl b::Tr for S {
    fn f() {
        3.f()
    }
}

Crate b:

pub trait Tr {
    fn f() // <-- new line is needed to trigger the ICE
        where Self: Sized;
}

Output:

error: no method named `f` found for type `{integer}` in the current scope
 --> src/lib.rs:5:11
  |
5 |         3.f()
  |           ^
  |
  = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
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 'byte index 4 is out of bounds of ``', src/libcore/str/mod.rs:2162
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: Could not compile `a`.

Rust stable (1.17.0) doesn't ICE, but produces a span that refers to no source code.

error: no method named `f` found for type `{integer}` in the current scope
 --> src/lib.rs:5:11
  |
5 |         3.f()
  |           ^
  |
  = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: candidate #1 is defined in the trait `b::Tr`
 --> b/src/lib.rs:2:5
  |
2 | 
  |  _____^ starting here...
3 | |
  | |__________________________^ ...ending here
  = help: to disambiguate the method call, write `b::Tr::f(3)` instead

error: aborting due to previous error

error: Could not compile `a`.

To learn more, run the command again with --verbose.

(BTW your code is wrong anyway, there are no Deserializer::deserialize methods in serde 1.0)

@messense
Copy link
Contributor Author

messense commented May 1, 2017

@kennytm I know the code is wrong, I was trying to let the compiler guide me through the upgrading process then it panicked.

kennytm added a commit to kennytm/rust that referenced this issue May 3, 2017
Don't print the source code in emit_message_default() and
render_source_line() if the source code is None.
bors added a commit that referenced this issue May 7, 2017
Fix issue #41652

Fix issue #41652. Don't print anything in `render_source_line()` if no source code is given.

(cc @jonathandturner #34789)
@messense messense closed this as completed Jul 3, 2017
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

3 participants