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

thread 'rustc' panicked at 'called Option::unwrap() on a None value #92195

Closed
bert2 opened this issue Dec 22, 2021 · 11 comments
Closed

thread 'rustc' panicked at 'called Option::unwrap() on a None value #92195

bert2 opened this issue Dec 22, 2021 · 11 comments
Labels
A-incr-comp Area: Incremental compilation 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.

Comments

@bert2
Copy link

bert2 commented Dec 22, 2021

Code

Only can provide an unminified repro right now, located in this repo (branch rustc-bug-repro)

If you check out the previous commit the build will go through without any compiler errors or rustc panics:

PS> git branch
  master
* rustc-bug-repro
PS> git checkout HEAD^ 
Note: switching to 'HEAD^'.
[...]
HEAD is now at b1f9ba6 split up expr into col names and literals
PS> cargo build
   Compiling sqlite-starter-rust v0.1.0 (C:\DEV\build-your-own-sqlite)
    Finished dev [unoptimized + debuginfo] target(s) in 0.99s

So it must be something that happend in this commit, but I can't say what exactly yet.

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-pc-windows-msvc
release: 1.57.0
LLVM version: 13.0.0

Error output

PS> cargo build
   Compiling sqlite-starter-rust v0.1.0 (C:\DEV\build-your-own-sqlite)
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\compiler\rustc_hir\src\definitions.rs:452:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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/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-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\compiler\rustc_hir\src\definitions.rs:452:14

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/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-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `sqlite-starter-rust`
RUST_BACKTRACE='full'

PS> cargo build
   Compiling sqlite-starter-rust v0.1.0 (C:\DEV\build-your-own-sqlite)
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\compiler\rustc_hir\src\definitions.rs:452:14
stack backtrace:
   0:     0x7ffc54c892cf - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h53606b08c01ef688
   1:     0x7ffc54cb306a - core::fmt::write::he97f21b785b90134
   2:     0x7ffc54c7b448 - <std::io::IoSlice as core::fmt::Debug>::fmt::h967100caef347f28
   3:     0x7ffc54c8cd96 - std::panicking::take_hook::hb46205f0055becfd
   4:     0x7ffc54c8c797 - std::panicking::take_hook::hb46205f0055becfd
   5:     0x7ffc5526a295 - <tracing_subscriber::fmt::writer::TestWriter as std::io::Write>::flush::hff7a705da113f4ca
   6:     0x7ffc54c8d6a9 - std::panicking::rust_panic_with_hook::hce0846b912adb5c5
   7:     0x7ffc54c8d11f - rust_begin_unwind
   8:     0x7ffc54c89bf7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h53606b08c01ef688
   9:     0x7ffc54c8d0a9 - rust_begin_unwind
  10:     0x7ffc54ce9510 - core::panicking::panic_fmt::h58715deff5969a45
  11:     0x7ffc54ce945c - core::panicking::panic::hc36befec1b90302c
  12:     0x7ffc58aeb97e - <rustc_query_impl::on_disk_cache::OnDiskCache as rustc_middle::ty::context::OnDiskCache>::def_path_hash_to_def_id::h9f7b03ae96e81f81
  13:     0x7ffc597feeb4 - rustc_middle::dep_graph::dep_node::<impl rustc_query_system::dep_graph::dep_node::DepNodeParams<rustc_middle::ty::context::TyCtxt> for rustc_span::def_id::LocalDefId>::recover::he3ec8272ca40aa05
  14:     0x7ffc58a11dad - rustc_query_impl::query_callbacks::hir_owner::force_from_dep_node::h913d78c1ee69fb04
  15:     0x7ffc58a6cb34 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h79c2867594abd9a1
  16:     0x7ffc58a6cb0b - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h79c2867594abd9a1
  17:     0x7ffc58a4497d - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h79c2867594abd9a1
  18:     0x7ffc5872b45e - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::hdad43e681eb5eae7
  19:     0x7ffc58a34333 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h79c2867594abd9a1
  20:     0x7ffc55428bae - rustc_interface::util::commit_date_str::h0a5e102287a616b6
  21:     0x7ffc553d8cd5 - rustc_interface::passes::analysis::hc0b219c9fceabc88
  22:     0x7ffc553b9321 - rustc_interface::queries::Linker::link::h24820195fd91a4b8
  23:     0x7ffc5545b2e5 - rustc_interface::passes::boxed_resolver::BoxedResolver::to_resolver_outputs::h32390bfacafe234b
  24:     0x7ffc553d3eb2 - rustc_interface::passes::analysis::hc0b219c9fceabc88
  25:     0x7ffc589eb8eb - ZN16rustc_query_impl13on_disk_cache260_$LT$impl$u20$rustc_serialize..serialize..Decodable$LT$rustc_query_impl..on_disk_cache..CacheDecoder$GT$$u20$for$u20$$RF$std..collections..hash..set..HashSet$LT$rustc_span..def_id..LocalDefId$C$core..hash..BuildHasher
  26:     0x7ffc58a7c61d - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h79c2867594abd9a1
  27:     0x7ffc589c2972 - <rustc_span::def_id::LocalDefId as rustc_query_impl::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string::h641e5a6d4a18de66
  28:     0x7ffc58764849 - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::hdad43e681eb5eae7
  29:     0x7ffc58a2e095 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h79c2867594abd9a1
  30:     0x7ffc552be59a - <tracing_subscriber::util::TryInitError as core::fmt::Display>::fmt::h8e44660347c50da5
  31:     0x7ffc55288944 - rustc_driver::pretty::print_after_hir_lowering::h16ae7f3f7d316762
  32:     0x7ffc552c07e6 - <tracing_subscriber::util::TryInitError as core::fmt::Display>::fmt::h8e44660347c50da5
  33:     0x7ffc5528ed63 - rustc_driver::pretty::print_after_hir_lowering::h16ae7f3f7d316762
  34:     0x7ffc552e9a58 - <rustc_driver::args::Error as core::fmt::Debug>::fmt::h11014d06e9af86ea
  35:     0x7ffc54c99d8c - std::sys::windows::thread::Thread::new::h4046847bccf80b57
  36:     0x7ffce6987034 - BaseThreadInitThunk
  37:     0x7ffce7762651 - RtlUserThreadStart

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/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-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\compiler\rustc_hir\src\definitions.rs:452:14
stack backtrace:
   0:     0x7ffc54c892cf - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h53606b08c01ef688
   1:     0x7ffc54cb306a - core::fmt::write::he97f21b785b90134
   2:     0x7ffc54c7b448 - <std::io::IoSlice as core::fmt::Debug>::fmt::h967100caef347f28
   3:     0x7ffc54c8cd96 - std::panicking::take_hook::hb46205f0055becfd
   4:     0x7ffc54c8c797 - std::panicking::take_hook::hb46205f0055becfd
   5:     0x7ffc5526a295 - <tracing_subscriber::fmt::writer::TestWriter as std::io::Write>::flush::hff7a705da113f4ca
   6:     0x7ffc54c8d6a9 - std::panicking::rust_panic_with_hook::hce0846b912adb5c5
   7:     0x7ffc54c8d11f - rust_begin_unwind
   8:     0x7ffc54c89bf7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h53606b08c01ef688
   9:     0x7ffc54c8d0a9 - rust_begin_unwind
  10:     0x7ffc54ce9510 - core::panicking::panic_fmt::h58715deff5969a45
  11:     0x7ffc54ce945c - core::panicking::panic::hc36befec1b90302c
  12:     0x7ffc58aeb97e - <rustc_query_impl::on_disk_cache::OnDiskCache as rustc_middle::ty::context::OnDiskCache>::def_path_hash_to_def_id::h9f7b03ae96e81f81
  13:     0x7ffc597feeb4 - rustc_middle::dep_graph::dep_node::<impl rustc_query_system::dep_graph::dep_node::DepNodeParams<rustc_middle::ty::context::TyCtxt> for rustc_span::def_id::LocalDefId>::recover::he3ec8272ca40aa05
  14:     0x7ffc58a11dad - rustc_query_impl::query_callbacks::hir_owner::force_from_dep_node::h913d78c1ee69fb04
  15:     0x7ffc58a6cb34 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h79c2867594abd9a1
  16:     0x7ffc58a6cb0b - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h79c2867594abd9a1
  17:     0x7ffc58a4497d - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h79c2867594abd9a1
  18:     0x7ffc5872b81e - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::hdad43e681eb5eae7
  19:     0x7ffc58a326d0 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h79c2867594abd9a1
  20:     0x7ffc5539f24e - <rls_span::compiler::DiagnosticSpanMacroExpansion as core::fmt::Debug>::fmt::hd8fad7e8b9a18847
  21:     0x7ffc553b8f6c - rustc_interface::queries::Linker::link::h24820195fd91a4b8
  22:     0x7ffc5545b315 - rustc_interface::passes::boxed_resolver::BoxedResolver::to_resolver_outputs::h32390bfacafe234b
  23:     0x7ffc553d3eb2 - rustc_interface::passes::analysis::hc0b219c9fceabc88
  24:     0x7ffc589eb8eb - ZN16rustc_query_impl13on_disk_cache260_$LT$impl$u20$rustc_serialize..serialize..Decodable$LT$rustc_query_impl..on_disk_cache..CacheDecoder$GT$$u20$for$u20$$RF$std..collections..hash..set..HashSet$LT$rustc_span..def_id..LocalDefId$C$core..hash..BuildHasher
  25:     0x7ffc58a7c61d - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h79c2867594abd9a1
  26:     0x7ffc589c2972 - <rustc_span::def_id::LocalDefId as rustc_query_impl::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string::h641e5a6d4a18de66
  27:     0x7ffc58764849 - <rustc_mir_dataflow::framework::cursor::CursorPosition as core::fmt::Debug>::fmt::hdad43e681eb5eae7
  28:     0x7ffc58a2e095 - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::try_mark_green::h79c2867594abd9a1
  29:     0x7ffc552be59a - <tracing_subscriber::util::TryInitError as core::fmt::Display>::fmt::h8e44660347c50da5
  30:     0x7ffc55288944 - rustc_driver::pretty::print_after_hir_lowering::h16ae7f3f7d316762
  31:     0x7ffc552c07e6 - <tracing_subscriber::util::TryInitError as core::fmt::Display>::fmt::h8e44660347c50da5
  32:     0x7ffc5528ed63 - rustc_driver::pretty::print_after_hir_lowering::h16ae7f3f7d316762
  33:     0x7ffc552e9a58 - <rustc_driver::args::Error as core::fmt::Debug>::fmt::h11014d06e9af86ea
  34:     0x7ffc54c99d8c - std::sys::windows::thread::Thread::new::h4046847bccf80b57
  35:     0x7ffce6987034 - BaseThreadInitThunk
  36:     0x7ffce7762651 - RtlUserThreadStart

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/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-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `sqlite-starter-rust`

@bert2 bert2 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 22, 2021
@bert2
Copy link
Author

bert2 commented Dec 22, 2021

I don't know what I did, but I can't reproduce it anymore. I started deleting and rebuilding until rustc didn't panice anymore. And now the unchanged repro can be built successfully too.

I guess the bug originated in the files rustc creates during builds for chaching or whatever and the repro wouldn't have worked on other machines anyway.

@95th
Copy link
Contributor

95th commented Dec 22, 2021

I was about to raise the same issue. Seems to be an issue with incremental build. cargo clean and cargo build resolves it and I can't replicate anymore.

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/compiler/rustc_hir/src/definitions.rs:452:14
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: <rustc_query_impl::on_disk_cache::OnDiskCache as rustc_middle::ty::context::OnDiskCache>::def_path_hash_to_def_id
   4: rustc_middle::dep_graph::dep_node::<impl rustc_query_system::dep_graph::dep_node::DepNodeParams<rustc_middle::ty::context::TyCtxt> for rustc_span::def_id::LocalDefId>::recover
   5: rustc_query_impl::query_callbacks::hir_owner::force_from_dep_node
   6: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
   7: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
   8: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_green
   9: rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory
  10: rustc_query_system::query::plumbing::try_execute_query
  11: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of
  12: <rustc_typeck::outlives::implicit_infer::InferVisitor as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item
  13: rustc_typeck::outlives::inferred_outlives_crate
  14: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  15: rustc_data_structures::stack::ensure_sufficient_stack
  16: rustc_query_system::query::plumbing::try_execute_query
  17: rustc_query_system::query::plumbing::force_query_impl
  18: rustc_query_impl::query_callbacks::inferred_outlives_crate::force_from_dep_node
  19: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
  20: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
  21: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
  22: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
  23: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_green
  24: rustc_query_system::query::plumbing::ensure_must_run
  25: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::collect_mod_item_types
  26: rustc_middle::hir::map::Map::for_each_module
  27: rustc_session::session::Session::track_errors
  28: rustc_typeck::check_crate
  29: rustc_interface::passes::analysis
  30: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  31: rustc_data_structures::stack::ensure_sufficient_stack
  32: rustc_query_system::query::plumbing::try_execute_query
  33: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  34: rustc_interface::passes::QueryContext::enter
  35: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  36: rustc_span::with_source_map
  37: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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/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-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
#0 [type_of] computing type of `asset::AssetKind::Links::links`
#1 [inferred_outlives_crate] computing the inferred outlives predicates for items in this crate
#2 [analysis] running analysis passes on this crate
end of query stack

@Aaron1011
Copy link
Member

This should be fixed on the latest nightly.

@95th
Copy link
Contributor

95th commented Dec 22, 2021

Since I can't replicate it anymore, I can't verify it.

@prismatic-obloquy
Copy link

Just hit this issue on stable with cargo check. Switching to (old) nightly leaves it there, so it's not going away just from switching versions. Updating to latest nightly fixes it and makes stable work again.

@HTGAzureX1212
Copy link
Contributor

This should be fixed on the latest nightly.

I have ran into a similar issue, but that also seems to be related to incremental compilation and is on latest nightly: #92221.

@BGR360
Copy link
Contributor

BGR360 commented Dec 23, 2021

@rustbot label +A-incr-comp

@95th
Copy link
Contributor

95th commented Dec 28, 2021

On latest nightly:

thread 'rustc' panicked at 'failed to lookup `SourceFile` in new context', compiler/rustc_query_impl/src/on_disk_cache.rs:500:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.59.0-nightly (f8abed9ed 2021-12-26) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack

cc @Aaron1011

@BGR360
Copy link
Contributor

BGR360 commented Dec 28, 2021

@95th I don't think that's the same ICE. Yours fails on compiler/rustc_query_impl/src/on_disk_cache.rs:500, while the one in this issue fails on compiler\rustc_hir\src\definitions.rs:452

See #92163

@95th
Copy link
Contributor

95th commented Dec 28, 2021

Oh you're right. I added my comment over there. Thanks

@workingjubilee
Copy link
Contributor

Closing as a probable duplicate of #91696

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation 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.
Projects
None yet
Development

No branches or pull requests

8 participants