Closed
Description
Hello,
During some attempts at figuring out how to maintain a static
vector (something I'm still not sure is actually possible, except maybe via lazy_static
?) through the lifetime of a program, I came across this compiler bug:
→ RUST_BACKTRACE=1 cargo build
Compiling static_vec_test v0.1.0 (redacted)
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 'index out of bounds: the len is 4 but the index is 6', src/libcollections/vec.rs:1166
stack backtrace:
1: 0x107664cc8 - std::sys::backtrace::tracing::imp::write::h4c73fcd3363076f5
2: 0x107671115 - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::h0422dbb3077e6747
3: 0x107670c4f - std::panicking::default_hook::haac48fa641db8fa2
4: 0x1076358a6 - std::sys_common::unwind::begin_unwind_inner::h39d40f52add53ef7
5: 0x1076379ae - std::sys_common::unwind::begin_unwind_fmt::h64c0ff793199cc1b
6: 0x1076624c7 - rust_begin_unwind
7: 0x1076a7730 - core::panicking::panic_fmt::h73bf9d7e8e891a73
8: 0x1076a7940 - core::panicking::panic_bounds_check::hc30e971884568c27
9: 0x106109779 - _<rustc_data_structures..unify..UnificationTable<K>>::get::he21ecf90e8e4f73a
10: 0x10609db34 - rustc::infer::InferCtxt::shallow_resolve::he47cdea6677f40d2
11: 0x106206e51 - rustc::traits::fulfill::process_predicate::h8bbef05b37cf149a
12: 0x106205c63 - _<rustc_data_structures..obligation_forest..ObligationForest<O, T>>::process_obligations::h824becaa5c013776
13: 0x1062012bc - rustc::traits::fulfill::FulfillmentContext::select_where_possible::hf3fc6484c301b5bb
14: 0x1039ab024 - rustc_typeck::check::FnCtxt::select_obligations_where_possible::h623b6ae6ad660b2d
15: 0x1039bd29c - rustc_typeck::check::FnCtxt::resolve_type_vars_if_possible::ha2a2b0468a33b7be
16: 0x1039d263a - rustc_typeck::check::demand::coerce::hd43013069440cf8a
17: 0x1039d39e2 - rustc_typeck::check::check_expr_with_expectation_and_lvalue_pref::h76666174c4b17386
18: 0x103a0af16 - rustc_typeck::check::check_stmt::h90d31dcbe73b93a2
19: 0x1039b0dc7 - rustc_typeck::check::check_block_with_expected::h17e4ec74708f2b9a
20: 0x1039d2e31 - rustc_typeck::check::check_expr_with_expectation_and_lvalue_pref::h76666174c4b17386
21: 0x1039b0f94 - rustc_typeck::check::check_block_with_expected::h17e4ec74708f2b9a
22: 0x1039a8408 - rustc_typeck::check::check_fn::hab7334b30b5aec4a
23: 0x1039a5ca7 - rustc_typeck::check::check_bare_fn::h85926feaf1e6659d
24: 0x1039a0b79 - rustc_typeck::check::check_item_body::h1895344155d5b2b2
25: 0x1039989fb - rustc_typeck::check::check_item_bodies::h525c1aa0e1abb529
26: 0x10399022b - rustc_typeck::check_crate::h0ef96f4043e1e69a
27: 0x103716e08 - rustc_driver::driver::phase_3_run_analysis_passes::_$u7b$$u7b$closure$u7d$$u7d$::hc699330eb6f2bc1e
28: 0x103715042 - rustc::ty::context::TyCtxt::create_and_enter::h656b2d3a4956519e
29: 0x10371198c - rustc_driver::driver::phase_3_run_analysis_passes::h83da042ec4b8ea10
30: 0x1036e5231 - rustc_driver::driver::compile_input::h6491aaddd9e61258
31: 0x1036cba4f - rustc_driver::run_compiler::h80b2ba5e4d787c5f
32: 0x1036c8de2 - std::sys_common::unwind::try::try_fn::h34e27823ddd1d5e9
33: 0x10766245b - __rust_try
34: 0x1076623e3 - std::sys_common::unwind::inner_try::h9eebd8dc83f388a6
35: 0x1036c9679 - _<F as std..boxed..FnBox<A>>::call_box::h3d5d78986dfac5b2
36: 0x10766ffe8 - std::sys::thread::Thread::new::thread_start::h471ad90789353b5b
37: 0x7fff98c3599c - _pthread_body
38: 0x7fff98c35919 - _pthread_start
error: Could not compile `static_vec_test`.
The code sample that triggers it is the following (prepare your eye baths now):
static mut v: &'static Option<Vec<u32>> = &None;
fn main() {
unsafe {
v = &mut Vec::new();
match v {
&None => println!("None"),
&Some(ref vec) => println!("{:?}", vec),
}
}
}
The output of rustic --verbose --version
is:
rustc 1.9.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-apple-darwin
release: 1.9.0
Hope this is useful to you!
Metadata
Metadata
Assignees
Labels
No labels