Skip to content

Index out of bounds panic when compiling project #54582

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
hallcristobal opened this issue Sep 26, 2018 · 4 comments
Closed

Index out of bounds panic when compiling project #54582

hallcristobal opened this issue Sep 26, 2018 · 4 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@hallcristobal
Copy link

hallcristobal commented Sep 26, 2018

When compiling my project TPGZ
on the branch "crashing" (which just has a lot of irrelevant things commented out) commenting out this array https://github.com/hallcristobal/TwilightPrincessDebugMenu/blob/b629f10f29810c3db4c5205619d71c79e552de1b/src/warping/statics/cave.rs#L53
(and the same similar arrays from the other files in that directory) causes it to not crash.

Meta

rustc --version --verbose:
rustc 1.30.0-nightly (2224a42 2018-09-17)
binary: rustc
commit-hash: 2224a42
commit-date: 2018-09-17
host: x86_64-pc-windows-msvc
release: 1.30.0-nightly
LLVM version: 8.0

Backtrace:

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', libcore\slice\mod.rs:2046:10
stack backtrace:
   0: <std::sys::windows::args::Args as core::ops::drop::Drop>::drop
   1: std::io::error::Error::get_ref
   2: std::panicking::take_hook
   3: std::panicking::take_hook
   4: <rustc::ty::sty::Binder<rustc::ty::ProjectionPredicate<'tcx>> as rustc::ty::ToPredicate<'tcx>>::to_predicate
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic_fmt
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::panicking::panic_bounds_check
  10: <rustc_lint::nonstandard_style::NonUpperCaseGlobals as rustc::lint::LateLintPass<'a, 'tcx>>::check_pat
  11: <rustc_lint::builtin::TypeAliasBounds as rustc::lint::LateLintPass<'a, 'tcx>>::check_item
  12: <rustc_lint::register_builtins::BuiltinCombinedLateLintPass as rustc::lint::LateLintPass<'a, 'tcx>>::check_item
  13: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  14: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  15: rustc::hir::intravisit::NestedVisitorMap::inter
  16: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  17: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  18: rustc::hir::intravisit::NestedVisitorMap::inter
  19: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  20: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  21: rustc::hir::intravisit::NestedVisitorMap::inter
  22: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  23: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  24: rustc::hir::intravisit::NestedVisitorMap::inter
  25: rustc::lint::context::check_crate
  26: <unknown>
  27: <rustc_driver::pretty::NoAnn<'hir> as rustc_driver::pretty::HirPrinterSupport<'hir>>::sess
  28: <rustc_driver::CompilationFailure as core::fmt::Debug>::fmt
  29: rustc_driver::driver::compile_input
  30: rustc_driver::run_compiler
  31: rustc_driver::target_features::add_configuration
  32: rustc_driver::run_compiler
  33: rustc_driver::target_features::add_configuration
  34: _rust_maybe_catch_panic
  35: rustc_driver::profile::dump
  36: rustc_driver::main
  37: <unknown>
  38: std::panicking::update_panic_count
  39: _rust_maybe_catch_panic
  40: std::rt::lang_start_internal
  41: <unknown>
  42: <unknown>
  43: BaseThreadInitThunk
  44: RtlUserThreadStart
query stack during panic:
end of query stack
@leonardo-m
Copy link

Could you create and copy here a minimized example of the problem?

@hallcristobal
Copy link
Author

I was able to get this to throw have the same panic

pub trait Stage: Sync {}

pub enum Enum {
	A,
	B,
}

impl Stage for Enum {}

pub static ARRAY: [(&Stage, &str); 1] = [
	(&Enum::A, ""),
];

If you remove the B type from Enum, it will not panic.
The length of ARRAY does not seem to effect it.

Should note this is on a slightly newer compiler (just performed rustup update on my current computer before performing this)

rustc 1.30.0-nightly (4141a4079 2018-09-25)
binary: rustc
commit-hash: 4141a4079e3e6b2c4ac104fed042a9b7241467eb
commit-date: 2018-09-25
host: x86_64-pc-windows-msvc
release: 1.30.0-nightly
LLVM version: 8.0

Backtrace:

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', libcore\slice\mod.rs:2103:10
stack backtrace:
   0: <std::sync::mpsc::RecvTimeoutError as core::fmt::Debug>::fmt
   1: <std::path::Iter<'a> as core::convert::AsRef<std::path::Path>>::as_ref
   2: std::panicking::take_hook
   3: std::panicking::take_hook
   4: rustc::ty::structural_impls::<impl rustc::ty::context::Lift<'tcx> for rustc::ty::adjustment::AutoBorrow<'a>>::lift_to_tcx
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic_fmt
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::panicking::panic_bounds_check
  10: <rustc_lint::nonstandard_style::NonUpperCaseGlobals as rustc::lint::LateLintPass<'a, 'tcx>>::check_pat
  11: <rustc_lint::builtin::TypeAliasBounds as rustc::lint::LateLintPass<'a, 'tcx>>::check_item
  12: <rustc_lint::register_builtins::BuiltinCombinedLateLintPass as rustc::lint::LateLintPass<'a, 'tcx>>::check_item
  13: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  14: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  15: rustc::hir::intravisit::NestedVisitorMap::inter
  16: rustc::lint::context::check_crate
  17: <humantime::date::Error as std::error::Error>::cause
  18: rustc_driver::target_features::add_configuration
  19: rustc_driver::profile::dump
  20: rustc_driver::driver::compile_input
  21: rustc_driver::run_compiler
  22: <rustc_driver::profile::trace::Query as core::fmt::Debug>::fmt
  23: rustc_driver::run_compiler
  24: <rustc_driver::profile::trace::Query as core::fmt::Debug>::fmt
  25: _rust_maybe_catch_panic
  26: rustc_driver::profile::dump
  27: rustc_driver::main
  28: <unknown>
  29: std::panicking::update_panic_count
  30: _rust_maybe_catch_panic
  31: std::rt::lang_start_internal
  32: <unknown>
  33: <unknown>
  34: BaseThreadInitThunk
  35: RtlUserThreadStart
query stack during panic:
end of query stack

@estebank
Copy link
Contributor

No longer reproduces in current stable.

@estebank estebank added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. labels Jan 19, 2019
@hallcristobal
Copy link
Author

Can confirm, no longer having issues with same implementation.

estebank added a commit to estebank/rust that referenced this issue Jan 21, 2019
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jan 21, 2019
Centril added a commit to Centril/rust that referenced this issue Jan 21, 2019
Centril added a commit to Centril/rust that referenced this issue Jan 22, 2019
bors added a commit that referenced this issue Jan 22, 2019
Rollup of 9 pull requests

Successful merges:

 - #57537 (Small perf improvement for fmt)
 - #57552 (Default images)
 - #57604 (Make `str` indexing generic on `SliceIndex`.)
 - #57667 (Fix memory leak in P::filter_map)
 - #57677 (const_eval: Predetermine the layout of all locals when pushing a stack frame)
 - #57791 (Add regression test for #54582)
 - #57798 (Corrected spelling inconsistency)
 - #57809 (Add powerpc64-unknown-freebsd)
 - #57813 (fix validation range printing when encountering undef)

Failed merges:

r? @ghost
VardhanThigle pushed a commit to jethrogb/rust that referenced this issue Jan 31, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
Development

No branches or pull requests

3 participants