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

error: internal compiler error: drop of untracked, uninitialized value #91816

Closed
sigmaSd opened this issue Dec 12, 2021 · 7 comments · Fixed by #92207
Closed

error: internal compiler error: drop of untracked, uninitialized value #91816

sigmaSd opened this issue Dec 12, 2021 · 7 comments · Fixed by #92207
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@sigmaSd
Copy link

sigmaSd commented Dec 12, 2021

Code

The panic happens here https://github.com/sigmaSd/konster/blob/ice/src/kmap.rs#L16

Meta

rustc --version --verbose:

rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0

Error output

error: internal compiler error: compiler/rustc_mir_transform/src/elaborate_drops.rs:315:25: drop of untracked, uninitialized value bb8, place (((_1.0: kvec::KVec<(K, V), N>).0: [(K, V); N])[_22].1: V) (Parent(Some(mp32)))

Backtrace

error: internal compiler error: compiler/rustc_mir_transform/src/elaborate_drops.rs:315:25: drop of untracked, uninitialized value bb8, place (((_1.0: kvec::KVec<(K, V), N>).0: [(K, V); N])[_22].1: V) (Parent(Some(mp32)))
  --> src/kmap.rs:16:17
   |
16 |                 self.vec.buf[self.vec.cursor - 1].1 = value;
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/compiler/rustc_errors/src/lib.rs:1092:9
stack backtrace:
   0:     0x7f1b1f85da9c - std::backtrace_rs::backtrace::libunwind::trace::hf6a6dfd7da937cb0
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f1b1f85da9c - std::backtrace_rs::backtrace::trace_unsynchronized::hc596a19e4891f7f3
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f1b1f85da9c - std::sys_common::backtrace::_print_fmt::hb16700db31584325
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f1b1f85da9c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h231c4190cfa75162
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f1b1f8bafdc - core::fmt::write::h2a1462b5f8eea807
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/fmt/mod.rs:1163:17
   5:     0x7f1b1f84dc05 - std::io::Write::write_fmt::h71ddfebc68685972
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/io/mod.rs:1696:15
   6:     0x7f1b1f860f60 - std::sys_common::backtrace::_print::hcc197d4bebf2b369
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f1b1f860f60 - std::sys_common::backtrace::print::h335a66af06738c7c
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f1b1f860f60 - std::panicking::default_hook::{{closure}}::h6fac9ac9c8b79e52
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:210:50
   9:     0x7f1b1f860b15 - std::panicking::default_hook::h341c1030c6a1161b
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:227:9
  10:     0x7f1b2004d2b1 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h932547f60770f26a
  11:     0x7f1b1f861779 - std::panicking::rust_panic_with_hook::h50680ff4b44510c6
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:628:17
  12:     0x7f1b202be00b - std::panicking::begin_panic::{{closure}}::h0125e1ff0bfe4e53
  13:     0x7f1b202bdfc6 - std::sys_common::backtrace::__rust_end_short_backtrace::hae1d67dea32e8035
  14:     0x7f1b2024ff0f - std::panicking::begin_panic::h521685e66fbb3433
  15:     0x7f1b202a740d - std::panic::panic_any::h9caaf7199e1644d6
  16:     0x7f1b202a33c5 - rustc_errors::HandlerInner::span_bug::hc9f0a930afc1d479
  17:     0x7f1b202a3640 - rustc_errors::Handler::span_bug::hc4af37c85eabc110
  18:     0x7f1b201f4bbd - rustc_middle::ty::context::tls::with_opt::h48190dd1f34ae5a2
  19:     0x7f1b201f6d80 - rustc_middle::util::bug::opt_span_bug_fmt::hcade798ef9e6d275
  20:     0x7f1b201f6d4c - rustc_middle::util::bug::span_bug_fmt::ha1d5b6fe1ca8882e
  21:     0x7f1b2133bf8f - <rustc_mir_transform::elaborate_drops::ElaborateDrops as rustc_middle::mir::MirPass>::run_pass::hb954d9506c1656cb
  22:     0x7f1b213632dc - rustc_mir_transform::run_passes::h0b0cae1798d554a0
  23:     0x7f1b21368e15 - rustc_mir_transform::run_post_borrowck_cleanup_passes::h34d80cbe976a7a80
  24:     0x7f1b213688f1 - rustc_mir_transform::mir_drops_elaborated_and_const_checked::he9672533e2b8a7b2
  25:     0x7f1b22295c9b - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::hceb6668af08c814b
  26:     0x7f1b2221a915 - rustc_data_structures::stack::ensure_sufficient_stack::h4ef639337d8f7956
  27:     0x7f1b217c44dc - rustc_query_system::query::plumbing::try_execute_query::hf3ffce6a38146ec3
  28:     0x7f1b21833d61 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_drops_elaborated_and_const_checked::ha3dc10083e60e48a
  29:     0x7f1b2126f630 - rustc_session::utils::<impl rustc_session::session::Session>::time::h8c394c39a2e108ce
  30:     0x7f1b21c57150 - rustc_interface::passes::analysis::h9fda1a8ae44d53e7
  31:     0x7f1b222713cf - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h26e86d963a73dec8
  32:     0x7f1b22216609 - rustc_data_structures::stack::ensure_sufficient_stack::h135baf7277c4d193
  33:     0x7f1b2213aa7b - rustc_query_system::query::plumbing::try_execute_query::h0bf7639d3f58bfbd
  34:     0x7f1b22253232 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis::ha2144cf05b40d10d
  35:     0x7f1b21c4bca9 - rustc_interface::passes::QueryContext::enter::h0523b23606206a0b
  36:     0x7f1b21c32977 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::hf84cd18c24bd5171
  37:     0x7f1b21c200ee - rustc_span::with_source_map::h6ab8a240e103b5b9
  38:     0x7f1b21c322ac - scoped_tls::ScopedKey<T>::set::hd1fbd64c6f645895
  39:     0x7f1b21c20ef5 - std::sys_common::backtrace::__rust_begin_short_backtrace::h0a1328c9fa7f7448
  40:     0x7f1b21c4c962 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h4ea1ced06d6b3e97
  41:     0x7f1b1f86c933 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7bd677a5dc988be6
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/alloc/src/boxed.rs:1691:9
  42:     0x7f1b1f86c933 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7b1c1ba11c4db785
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/alloc/src/boxed.rs:1691:9
  43:     0x7f1b1f86c933 - std::sys::unix::thread::Thread::new::thread_start::h9c58c0d12d84e854
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys/unix/thread.rs:106:17
  44:     0x7f1b1f766259 - start_thread
  45:     0x7f1b1f67b5e3 - __GI___clone
  46:                0x0 - <unknown>

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.57.0 (f1edd0429 2021-11-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C linker=/usr/bin/clang -C incremental -C link-arg=-fuse-ld=/home/mrcool/dev/bin/mold --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `kmap::<impl at src/kmap.rs:9:1: 24:2>::insert`
#1 [analysis] running analysis passes on this crate
end of query stack

@sigmaSd sigmaSd added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 12, 2021
@5225225
Copy link
Contributor

5225225 commented Dec 12, 2021

I can't seem to reproduce this locally, does it go away if you update your compiler?

@sigmaSd
Copy link
Author

sigmaSd commented Dec 12, 2021

Current compiler is: rustc 1.57.0 (f1edd04 2021-11-29)

And the same happens when I use beta and nightly:

beta: cargo 1.56.0-beta (18751dd3f 2021-09-01)
nightly: cargo 1.57.0-nightly (9a28ac83c 2021-09-18)

I remembered I was using mold linker (https://github.com/rui314/mold) but I switched to the default linker and the same happens, other then that my setup is normal

@sigmaSd
Copy link
Author

sigmaSd commented Dec 12, 2021

Actually I can confirm its reproducible, I just tried it with https://gitpod.io/ and the same thing happens

maybe you didn't checkout the ice branch?

@5225225
Copy link
Contributor

5225225 commented Dec 12, 2021

Ahhh, oops. Didn't notice it was on a different branch. Sorry, my bad! Yes, I can reproduce it fine locally.

@ecstatic-morse
Copy link
Contributor

ecstatic-morse commented Dec 12, 2021

MCVE:

struct S<T>([T; 1]);

impl<K, V> S<(K, V)> {
    pub const fn foo(mut self, value: V) -> Self {
        let _arr = self.0;
        self.0[0].1 = value; //~ move
        self
    }
}

fn main() {}

This code has move errors and fails const-checking, just like the original example. The ICE occurs after errors are emitted. @sigmaSd did you truncate the logs in your original post?

One option is to change the following statement to delay_span_bug:

span_bug!(
terminator.source_info.span,
"drop of untracked, uninitialized value {:?}, place {:?} ({:?})",
bb,
place,
path
);

It's a weird that the ICE only occurs only in a const-context though, perhaps there's a better way to fix this?

For the non-const version, we abort before we ever get to drop elaboration due to the errors, though I'm not sure why.

@tmiasko
Copy link
Contributor

tmiasko commented Dec 12, 2021

For the non-const version, we abort before we ever get to drop elaboration due to the errors, though I'm not sure why.

For const items mir_drops_elaborated_and_const_checked is queried earlier, without an intermediate exit point:

sess.time("MIR_borrow_checking", || {
tcx.hir().par_body_owners(|def_id| tcx.ensure().mir_borrowck(def_id));
});
sess.time("MIR_effect_checking", || {
for def_id in tcx.hir().body_owners() {
tcx.ensure().thir_check_unsafety(def_id);
if !tcx.sess.opts.debugging_opts.thir_unsafeck {
rustc_mir_transform::check_unsafety::check_unsafety(tcx, def_id);
}
if tcx.hir().body_const_context(def_id).is_some() {
tcx.ensure()
.mir_drops_elaborated_and_const_checked(ty::WithOptConstParam::unknown(def_id));
}
}
});
sess.time("layout_testing", || layout_test::test_layout(tcx));
// Avoid overwhelming user with errors if borrow checking failed.
// I'm not sure how helpful this is, to be honest, but it avoids a
// lot of annoying errors in the ui tests (basically,
// lint warnings and so on -- kindck used to do this abort, but
// kindck is gone now). -nmatsakis
if sess.has_errors() {
return Err(ErrorReported);
}

@sigmaSd
Copy link
Author

sigmaSd commented Dec 14, 2021

@ecstatic-morse yes the error log is truncated, I have a move error error[E0382]: assign to part of moved value: self.vec.buf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants