Skip to content

unexpected compiler panic in cast.rs #46365

Closed

Description

@avadacatavra

Not totally sure why this happened. When I forgot an extern crate the compiler panicked with the following 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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.23.0-nightly (e21df8020 2017-11-13) running on x86_64-apple-darwin

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'explicit panic', src/librustc_typeck/check/cast.rs:110:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic
   6: rustc_typeck::check::cast::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::pointer_kind
   7: rustc_typeck::check::cast::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::pointer_kind
   8: rustc_typeck::check::cast::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::pointer_kind
   9: rustc_typeck::check::cast::CastCheck::check
  10: rustc_typeck::check::FnCtxt::check_casts
  11: <std::thread::local::LocalKey<T>>::with
  12: rustc::ty::context::GlobalCtxt::enter_local
  13: _ZN12rustc_typeck5check16typeck_tables_of17h2991cb3aa7f93926E.llvm.5BE90B30
  14: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::compute_result
  15: _ZN5rustc9dep_graph5graph8DepGraph14with_task_impl17hdc0895b856803ac5E.llvm.E968ED05
  16: rustc_errors::Handler::track_diagnostics
  17: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  18: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::force
  19: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  20: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  21: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::ensure
  22: rustc::session::Session::track_errors
  23: _ZN12rustc_typeck5check18typeck_item_bodies17h619021d8d31ccdb0E.llvm.5BE90B30
  24: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::compute_result
  25: _ZN5rustc9dep_graph5graph8DepGraph14with_task_impl17h09adb0a33cf7a8d7E.llvm.E968ED05
  26: rustc_errors::Handler::track_diagnostics
  27: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  28: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::force
  29: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get
  30: rustc::ty::maps::TyCtxtAt::typeck_item_bodies
  31: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_item_bodies
  32: rustc_typeck::check_crate
  33: <std::thread::local::LocalKey<T>>::with
  34: <std::thread::local::LocalKey<T>>::with
  35: rustc::ty::context::TyCtxt::create_and_enter
  36: rustc_driver::driver::compile_input
  37: rustc_driver::run_compiler

Activity

  1. kennytm commented on Nov 29, 2017

    @kennytm
    Member

    Hi do you have the code that caused this bug? Thanks!

  2. added
    C-bugCategory: This is a bug.
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on Nov 29, 2017
  3. avadacatavra commented on Nov 29, 2017

    @avadacatavra
    Author

    Instead of using std::cell::{Ref, RefCell, RefMut};, I switched to use accountable_refcell::{RefCell, Ref, RefMut}; in https://dxr.mozilla.org/servo/source/components/script/dom/bindings/cell.rs#7

    accountable_refcell was in the Cargo.toml, but I'd forgotten to put an extern crate in lib.rs. Then I ran ./mach check (equiv to cargo check)

  4. kennytm commented on Nov 29, 2017

    @kennytm
    Member

    @avadacatavra I just noticed that the nightly version in the report is rustc 1.23.0-nightly (e21df8020 2017-11-13). Could you update the nightly to the current one (1.24.0-nightly (73bca2b9f 2017-11-28)) and try again?

  5. arielb1 commented on Nov 29, 2017

    @arielb1
    Contributor

    This reproduces the ICE (on beta but not on stable)

    use std::fmt;
    fn main() {
        let foo: *mut (fmt::Display,) = 0 as *mut _;
    }

    Now the question is whether @avadacatavra had a different reproduction

  6. Deewiant commented on Dec 22, 2017

    @Deewiant
    Contributor

    Bisecting using @arielb1's latest example points to #44295 as the cause. (Not sure exactly which commit — the three commits preceding 1e9e319 don't compile and I didn't feel like sorting it out.)

  7. arielb1 commented on Dec 23, 2017

    @arielb1
    Contributor

    So I found the "real" example:

    use std::fmt;
    struct Lorem {
        ipsum: Ipsum
    }
    fn main() {
        let foo: *mut Lorem = 0 as *mut _;
    }
  8. added 2 commits that reference this issue on Jun 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions