Skip to content

Compiler error: thread 'rustc' panicked at 'Box<dyn Any>' #105529

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

Closed
rayhem opened this issue Dec 10, 2022 · 3 comments
Closed

Compiler error: thread 'rustc' panicked at 'Box<dyn Any>' #105529

rayhem opened this issue Dec 10, 2022 · 3 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

@rayhem
Copy link

rayhem commented Dec 10, 2022

Code

You can see the full context for the change that triggered the panic at https://github.com/rayhem/advent/commit/99a2921e828506bc66a09da793f73710e68d6413.

Long story short, I was working on generalizing some execution + display code for this year's Advent of Code. I believe this issue arose due to an interaction with this function,

pub fn execute_with_timing<P: Puzzle>(
    input_file: &std::path::Path,
    puzzle: P,
) -> std::result::Result<TimedResults, Error>

and how I store my puzzles,

let mut puzzles: HashMap<i32, Box<dyn Puzzle>> = HashMap::new();
// ...
let timed_results = execute_with_timing(&filename, puzzles.get(&1))?;

as this was the section of code I was working on refactoring.

Meta

rustc --version --verbose:

rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: x86_64-unknown-linux-gnu
release: 1.65.0
LLVM version: 15.0.0

Error output

See errorlog.txt for a full log.

error: internal compiler error: compiler/rustc_middle/src/ty/context.rs:703:13: node_type: no type for node `expr {
                                        let res = $crate::fmt::format($crate::__export::format_args!($($arg)*));
                                        res
                                    } (hir_id=HirId { owner: DefId(0:72 ~ 2022[472a]::main), local_id: 265 })`
Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/897e37553bba8b42751c67658967889d11ecd120/compiler/rustc_errors/src/lib.rs:1462:9
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner>::bug::<&alloc::string::String>
   3: <rustc_errors::Handler>::bug::<&alloc::string::String>
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
   5: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
   6: rustc_middle::util::bug::bug_fmt
   7: <rustc_middle::ty::context::TypeckResults>::expr_ty_adjusted
   8: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt>::note_obligation_cause_code::<rustc_middle::ty::Predicate>
   9: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::note_obligation_cause
  10: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_selection_error
  11: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt>::report_fulfillment_error
  12: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::error_reporting::InferCtxtExt>::report_fulfillment_errors
  13: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
  14: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  15: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_decl
  16: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  17: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  18: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  20: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  21: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_match::{closure#0}
  22: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  23: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  24: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_match::{closure#0}
  26: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  27: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
  29: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30: <rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
  31: rustc_typeck::check::check::check_fn
  32: <rustc_infer::infer::InferCtxtBuilder>::enter::<&rustc_middle::ty::context::TypeckResults, <rustc_typeck::check::inherited::InheritedBuilder>::enter<rustc_typeck::check::typeck_with_fallback<rustc_typeck::check::typeck::{closure#0}>::{closure#1}, &rustc_middle::ty::context::TypeckResults>::{closure#0}>
  33: rustc_typeck::check::typeck
  34: <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, &rustc_middle::ty::context::TypeckResults>
  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, &rustc_middle::ty::context::TypeckResults>>
  36: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  37: rustc_data_structures::sync::par_for_each_in::<&[rustc_span::def_id::LocalDefId], <rustc_middle::hir::map::Map>::par_body_owners<rustc_typeck::check::typeck_item_bodies::{closure#0}>::{closure#0}>
  38: rustc_typeck::check::typeck_item_bodies
  39: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), ()>
  40: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), ()>>
  41: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::typeck_item_bodies, rustc_query_impl::plumbing::QueryCtxt>
  42: <rustc_session::session::Session>::time::<(), rustc_typeck::check_crate::{closure#7}>
  43: rustc_typeck::check_crate
  44: rustc_interface::passes::analysis
  45: <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::ErrorGuaranteed>>
  46: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorGuaranteed>>>
  47: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  48: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
  49: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  50: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>

@rayhem rayhem 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 10, 2022
@inquisitivecrystal inquisitivecrystal added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Dec 11, 2022
@rayhem
Copy link
Author

rayhem commented Dec 11, 2022

Digging deeper, this is trivially reproducible with the following in my environment:

fn main() {
    let filename = std::path::Path::from(format!("{}/day{:02}.txt", "foobar", 01));
}

Running this with nightly produces E0277, E0308, and E0277 errors indicating the path doesn't have a size at compile time (probably the correct behavior).

@inquisitivecrystal inquisitivecrystal removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Dec 12, 2022
@albertlarsan68
Copy link
Member

I ran cargo bisect-rustc on the code above, and here is the result, where regression means ICE disappeared:

searched nightlies: from nightly-2022-09-17 to nightly-2022-12-12
regressed nightly: nightly-2022-09-20
searched commit range: a37499a...2019147
regressed commit: 503e19d #101629 (cc @compiler-errors)

bisected with cargo-bisect-rustc v0.6.4

Host triple: x86_64-pc-windows-msvc
Reproduce with:

cargo bisect-rustc --access=github --start 1.65.0 --end 2022-12-12 --regress=non-ice -- check

@compiler-errors
Copy link
Member

This is landing in 1.66 which will come in a few days.

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

4 participants