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

cargo check panic at 'failed to lookup SourceFile in new context' after refactor #92595

Closed
TimJentzsch opened this issue Jan 5, 2022 · 7 comments
Labels
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

@TimJentzsch
Copy link

This error occurred when running cargo check after refactoring a module folder to a module file.

Meta

rustc --version --verbose:

rustc 1.59.0-nightly (7d6f94817 2022-01-04)
binary: rustc
commit-hash: 7d6f948173ccb18822bab13d548c65632db5f0aa
commit-date: 2022-01-04
host: x86_64-unknown-linux-gnu
release: 1.59.0-nightly
LLVM version: 13.0.0

Error output

thread 'rustc' panicked at 'failed to lookup `SourceFile` in new context', compiler/rustc_query_impl/src/on_disk_cache.rs:514:22

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 (7d6f94817 2022-01-04) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [type_of] computing type of `stonefish::node::Node::evaluation`
#1 [inferred_outlives_crate] computing the inferred outlives predicates for items in this crate
#2 [collect_mod_item_types] collecting item types in module `stonefish`
#3 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `stonefish_engine`
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/7d6f948173ccb18822bab13d548c65632db5f0aa/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/7d6f948173ccb18822bab13d548c65632db5f0aa/library/core/src/panicking.rs:107:14
   2: core::panicking::panic_display
             at /rustc/7d6f948173ccb18822bab13d548c65632db5f0aa/library/core/src/panicking.rs:63:5
   3: core::panicking::panic_str
             at /rustc/7d6f948173ccb18822bab13d548c65632db5f0aa/library/core/src/panicking.rs:55:5
   4: core::option::expect_failed
             at /rustc/7d6f948173ccb18822bab13d548c65632db5f0aa/library/core/src/option.rs:1817:5
   5: <rustc_span::span_encoding::Span as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
   6: <rustc_middle::ty::VariantDef as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
   7: <rustc_query_impl::on_disk_cache::CacheDecoder as rustc_serialize::serialize::Decoder>::read_seq::<alloc::vec::Vec<rustc_middle::ty::VariantDef>, <alloc::vec::Vec<rustc_middle::ty::VariantDef> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>
   8: <rustc_middle::ty::adt::AdtDef as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
   9: <rustc_middle::ty::sty::TyKind as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  10: <&rustc_middle::ty::TyS as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  11: <&rustc_middle::ty::TyS as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  12: <rustc_query_impl::on_disk_cache::OnDiskCache>::try_load_query_result::<&rustc_middle::ty::TyS>
  13: rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::DefId, &rustc_middle::ty::TyS>
  14: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of
  15: <rustc_typeck::outlives::implicit_infer::InferVisitor as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_item
  16: <rustc_middle::hir::map::Map>::visit_all_item_likes::<rustc_typeck::outlives::implicit_infer::InferVisitor>
  17: rustc_typeck::outlives::inferred_outlives_crate
  18: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task_impl<rustc_middle::ty::context::TyCtxt, (), rustc_middle::ty::CratePredicatesMap>::{closure#0}, rustc_middle::ty::CratePredicatesMap>
  19: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), rustc_middle::ty::CratePredicatesMap>
  20: rustc_data_structures::stack::ensure_sufficient_stack::<(rustc_middle::ty::CratePredicatesMap, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (), rustc_middle::ty::CratePredicatesMap>::{closure#3}>
  21: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::ArenaCache<(), rustc_middle::ty::CratePredicatesMap>>
  22: rustc_query_system::query::plumbing::force_query::<rustc_query_impl::queries::inferred_outlives_crate, rustc_query_impl::plumbing::QueryCtxt>
  23: rustc_query_impl::query_callbacks::inferred_outlives_crate::force_from_dep_node
  24: <rustc_middle::ty::context::TyCtxt as rustc_query_system::dep_graph::DepContext>::try_force_from_dep_node
  25: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  26: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  27: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  28: rustc_query_system::query::plumbing::ensure_must_run::<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::DefId, rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs>
  29: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::predicates_of
  30: <rustc_typeck::collect::CollectItemTypesVisitor as rustc_hir::intravisit::Visitor>::visit_item
  31: <rustc_middle::hir::map::Map>::visit_item_likes_in_module::<rustc_hir::intravisit::DeepVisitor<rustc_typeck::collect::CollectItemTypesVisitor>>
  32: rustc_typeck::collect::collect_mod_item_types
  33: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, ()>
  34: rustc_data_structures::stack::ensure_sufficient_stack::<((), rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::LocalDefId, ()>::{closure#3}>
  35: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, ()>>
  36: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::collect_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
  37: <rustc_middle::hir::map::Map>::for_each_module::<rustc_typeck::check_crate::{closure#0}::{closure#0}::{closure#0}>
  38: <rustc_session::session::Session>::track_errors::<rustc_typeck::check_crate::{closure#0}, ()>
  39: rustc_typeck::check_crate
  40: rustc_interface::passes::analysis
  41: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>
  42: rustc_data_structures::stack::ensure_sufficient_stack::<(core::result::Result<(), rustc_errors::ErrorReported>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>::{closure#3}>
  43: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorReported>>>
  44: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  45: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorReported>>
  46: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
  47: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  48: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>

@TimJentzsch TimJentzsch 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 Jan 5, 2022
@TimJentzsch
Copy link
Author

Everything works again after running cargo clean and then cargo check.

@TimJentzsch
Copy link
Author

TimJentzsch commented Jan 5, 2022

I wasn't able to set up a minimal example for this bug yet, but you can use my public repository to reproduce:

  1. Clone the repository from https://github.com/TimJentzsch/stonefish_engine:
    git clone [email protected]:TimJentzsch/stonefish_engine.git
    cd stonefish_engine
    
  2. Checkout the commit before the refactor:
    git checkout a2846edcbd36bf51583d9d10538ec1907526060d
    
  3. Run cargo check from a clean state:
    cargo clean && cargo check
    
  4. Checkout the commit after the refactor:
    git checkout 185120025c7e48f433e85faeaa910544d1871d11
    
  5. Run cargo check again:
    cargo check
    
  6. The compiler panics:
    thread 'rustc' panicked at 'failed to lookup `SourceFile` in new context', compiler/rustc_query_impl/src/on_disk_cache.rs:514: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 (7d6f94817 2022-01-04) running on x86_64-unknown-linux-gnu
    
    note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin
    
    note: some of the compiler flags provided by cargo are hidden
    
    query stack during panic:
    #0 [type_of] computing type of `stonefish::node::Node::evaluation`
    #1 [inferred_outlives_crate] computing the inferred outlives predicates for items in this crate
    end of query stack
    error: could not compile `stonefish_engine`
    

@TimJentzsch TimJentzsch changed the title cargo check panic at 'failed to lookup SourceFile in new context' cargo check panic at 'failed to lookup SourceFile in new context' after refactor Jan 5, 2022
@Aaron1011
Copy link
Member

Based on the fact that you're using such a recent nightly, this does not appear to be the same issue as #92163

I suspect that this will be fixed by #92533

@sourcefrog
Copy link
Contributor

In case it's helpful: I also hit this only once on v0.0.212-9018-g917890bab of rust-clippy, but couldn't reproduce it after cargo clean.

@philipcraig
Copy link
Contributor

Hi everyone, this bug in beta is so prevalent that lots of tests in https://github.com/google/autocxx/blob/main/integration-tests/tests/integration_test.rs have had to be disabled for beta builds. Incremental compiles fail crazily often, and it is breaking the integration tests that use beta channel on the CI, always with this same compile panic.

If the beta channel gets promoted to stable in this state, it will look like a major compilation regression for many rustc users, and will have to be urgently patched in a .1 release post-promotion

@TimJentzsch
Copy link
Author

TimJentzsch commented Feb 22, 2022

@philipcraig You should probably open a new issue for this, I just tested this scenario again and it seems to compile without errors now.

I'll probably close this issue soon

@ehuss
Copy link
Contributor

ehuss commented Mar 24, 2022

Closing as I believe this is now resolved.

@ehuss ehuss closed this as completed Mar 24, 2022
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. 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

5 participants