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

unexpected compiler panic in cast.rs #46365

Closed
avadacatavra opened this issue Nov 29, 2017 · 6 comments
Closed

unexpected compiler panic in cast.rs #46365

avadacatavra opened this issue Nov 29, 2017 · 6 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta.

Comments

@avadacatavra
Copy link

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
@kennytm
Copy link
Member

kennytm commented Nov 29, 2017

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

@kennytm kennytm added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Nov 29, 2017
@avadacatavra
Copy link
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)

@kennytm
Copy link
Member

kennytm commented Nov 29, 2017

@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?

@arielb1
Copy link
Contributor

arielb1 commented Nov 29, 2017

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

@arielb1 arielb1 added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Dec 20, 2017
@Deewiant
Copy link
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.)

@arielb1
Copy link
Contributor

arielb1 commented Dec 23, 2017

So I found the "real" example:

use std::fmt;
struct Lorem {
    ipsum: Ipsum
}
fn main() {
    let foo: *mut Lorem = 0 as *mut _;
}

bors added a commit that referenced this issue Dec 25, 2017
Update check::cast::pointer_kind logic to new rustc

Make the match exhaustive, adding handling for anonymous types and
tuple coercions on the way.

Also, exit early when type errors are detected, to avoid error cascades
and the like.

Fixes #33690.
Fixes #46365.
Fixes #46880.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 5, 2022
…crum

Restore a test that was intended to test `as` cast to ptr

This test was changed in rust-lang#61864, but the original bug rust-lang#46365 was about casts so I doubt the changed test still even tests what this was intended to test. Let's restore the original test.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 6, 2022
…crum

Restore a test that was intended to test `as` cast to ptr

This test was changed in rust-lang#61864, but the original bug rust-lang#46365 was about casts so I doubt the changed test still even tests what this was intended to test. Let's restore the original test.
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) ❄️ regression-from-stable-to-beta Performance or correctness regression from stable to beta.
Projects
None yet
Development

No branches or pull requests

4 participants