gimli-rs / gimli

A library for reading and writing the DWARF debugging format

Home Page:https://docs.rs/gimli/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

index out of bounds: the len is 0 but the index is 0'

bjorn3 opened this issue · comments

https://github.com/bjorn3/rustc_codegen_cranelift/tree/update_gimli

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/147311c5fc62537da8eb9c6f69536bec6719d534/src/libcore/slice/mod.rs:2535:10
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:482
   6: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:385
   7: rust_begin_unwind
             at src/libstd/panicking.rs:312
   8: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
   9: core::panicking::panic_bounds_check
             at src/libcore/panicking.rs:61
  10: <usize as core::slice::SliceIndex<[T]>>::index
             at /rustc/147311c5fc62537da8eb9c6f69536bec6719d534/src/libcore/slice/mod.rs:2535
  11: core::slice::<impl core::ops::index::Index<I> for [T]>::index
             at /rustc/147311c5fc62537da8eb9c6f69536bec6719d534/src/libcore/slice/mod.rs:2392
  12: <alloc::vec::Vec<T> as core::ops::index::Index<I>>::index
             at /rustc/147311c5fc62537da8eb9c6f69536bec6719d534/src/liballoc/vec.rs:1678
  13: gimli::write::range::RangeListOffsets::get
             at /home/bjorn/.cargo/git/checkouts/gimli-a0d193bd15a5ed96/c679a14/src/write/mod.rs:76
  14: gimli::write::unit::AttributeValue::write
             at /home/bjorn/.cargo/git/checkouts/gimli-a0d193bd15a5ed96/c679a14/src/write/unit.rs:955
  15: gimli::write::unit::Attribute::write
             at /home/bjorn/.cargo/git/checkouts/gimli-a0d193bd15a5ed96/c679a14/src/write/unit.rs:573
  16: gimli::write::unit::DebuggingInformationEntry::write
             at /home/bjorn/.cargo/git/checkouts/gimli-a0d193bd15a5ed96/c679a14/src/write/unit.rs:485
  17: gimli::write::unit::CompilationUnit::write
             at /home/bjorn/.cargo/git/checkouts/gimli-a0d193bd15a5ed96/c679a14/src/write/unit.rs:274
  18: gimli::write::unit::UnitTable::write
             at /home/bjorn/.cargo/git/checkouts/gimli-a0d193bd15a5ed96/c679a14/src/write/unit.rs:97
  19: rustc_codegen_cranelift::debuginfo::DebugContext::emit
             at src/debuginfo.rs:219
  20: <rustc_codegen_cranelift::CraneliftCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate::{{closure}}
             at src/lib.rs:280
  21: <rustc_codegen_cranelift::CraneliftCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
             at src/lib.rs:316
  22: rustc::util::common::time
  23: rustc_driver::driver::phase_4_codegen
  24: rustc_driver::driver::compile_input::{{closure}}
  25: <std::thread::local::LocalKey<T>>::with
  26: rustc::ty::context::TyCtxt::create_and_enter
  27: rustc_driver::driver::compile_input
  28: rustc_driver::run_compiler_with_pool
  29: <scoped_tls::ScopedKey<T>>::set
  30: rustc_driver::run_compiler
  31: <scoped_tls::ScopedKey<T>>::set
query stack during panic:
end of query stack

You need to add ranges to CompilationUnit::ranges. Do not use your own RangeListTable.

I wonder if we can add a table id to identifiers, so that we can check if the wrong table is being used.

You need to add ranges to CompilationUnit::ranges.

Didn't know that changed :)