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

ICE: trivial_numeric_casts when using SDL on nightly #42007

Closed
andrewhickman opened this issue May 15, 2017 · 2 comments
Closed

ICE: trivial_numeric_casts when using SDL on nightly #42007

andrewhickman opened this issue May 15, 2017 · 2 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.

Comments

@andrewhickman
Copy link
Contributor

Compiling this short snippet causes a compiler panic

extern crate sdl2;

use sdl2::mouse::MouseButton;

enum Input {
    MouseButton(MouseButton),
}

fn main() {}

Compiler version:

PS C:\Users\me\Documents\rust\sdltest> rustc --version --verbose
rustc 1.17.0 (56124baa9 2017-04-24)
binary: rustc
commit-hash: 56124baa9e73f28c0709e59e74783cf234a978cf
commit-date: 2017-04-24
host: x86_64-pc-windows-msvc
release: 1.17.0
LLVM version: 3.9

SDL version was 0.29.0.

Backtrace:

PS C:\Users\me\Documents\rust\sdltest> cargo +nightly build
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling sdl2-sys v0.27.3
   Compiling sdltest v0.1.0 (file:///C:/Users/me/Documents/rust/sdltest)
   Compiling sdl2 v0.29.1
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: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'invalid lint-id `trivial_numeric_casts`', src\librustc\lint\context.rs:1322
stack backtrace:
   0: <std::time::SystemTimeError as core::fmt::Display>::fmt
   1: std::panicking::Location::line
   2: std::panicking::Location::line
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic_fmt
   5: std::panicking::begin_panic_fmt
   6: <unknown>
   7: rustc_metadata::decoder::<impl rustc_metadata::cstore::CrateMetadata>::item_body_tables
   8: rustc_metadata::cstore_impl::provide
   9: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  10: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  11: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
  12: rustc_const_eval::eval::provide
  13: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get
  14: rustc::ty::maps::TyCtxtAt::const_eval
  15: rustc::ty::layout::Layout::compute_uncached
  16: rustc::ty::util::<impl rustc::ty::TyS<'tcx>>::needs_drop_uncached
  17: <rustc::util::common::Indenter as core::ops::Drop>::drop
  18: rustc::ty::layout::Layout::compute_uncached
  19: <rustc_lint::types::VariantSizeDifferences as rustc::lint::LateLintPass<'a, 'tcx>>::check_item
  20: rustc::lint::context::gather_attrs
  21: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  22: rustc::lint::context::check_crate
  23: rustc_driver::driver::count_nodes
  24: rustc_driver::driver::count_nodes
  25: rustc_driver::driver::compile_input
  26: rustc_driver::run_compiler
  27: <unknown>
  28: _rust_maybe_catch_panic
  29: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_impl_item
  30: std::sys::imp::thread::Thread::new
  31: BaseThreadInitThunk

error: Could not compile `sdltest`.

To learn more, run the command again with --verbose.
@nagisa nagisa added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 15, 2017
@est31
Copy link
Member

est31 commented May 15, 2017

Minimal reproducible example (without sdl2 requirement):

lib.rs of crate "s":

#[repr(u8)]
pub enum E {
    B = 1 as u8,
}

main.rs of crate "t":

extern crate s;

enum I {
    E(s::E),
}

fn main() {}

@kennytm
Copy link
Member

kennytm commented May 15, 2017

No repro on stable (Regression).

The error on this line (<LintId as Decodable>::decode()) is FindLintError::NotFound. The LintStore is actually empty at this point.

The LintStore becomes empty due to check_crate temporarily moving out the LintStore until the end of the function. But walk_crate eventually needs to decode the crate "s", which has an trivial_numeric_casts lint that is not found in the empty LintStore.

Very detailed stack trace when nothing is inlined
   7: std::panicking::begin_panic_fmt
   8: rustc::lint::context::<impl serialize::serialize::Decodable for rustc::lint::LintId>::decode::{{closure}}
   9: rustc::ty::context::tls::with::{{closure}}
  10: <std::thread::local::LocalKey<T>>::with
  11: rustc::ty::context::tls::with
  12: rustc::lint::context::<impl serialize::serialize::Decodable for rustc::lint::LintId>::decode
  13: core::ops::FnOnce::call_once
  14: serialize::serialize::Decoder::read_struct_field
  15: <rustc::lint::context::EarlyLint as serialize::serialize::Decodable>::decode::{{closure}}
  16: serialize::serialize::Decoder::read_struct
  17: <rustc::lint::context::EarlyLint as serialize::serialize::Decodable>::decode
  18: <collections::vec::Vec<T> as serialize::serialize::Decodable>::decode::{{closure}}::{{closure}}
  19: serialize::serialize::Decoder::read_seq_elt
  20: <collections::vec::Vec<T> as serialize::serialize::Decodable>::decode::{{closure}}
  21: serialize::serialize::Decoder::read_seq
  22: <collections::vec::Vec<T> as serialize::serialize::Decodable>::decode
  23: serialize::collection_impls::<impl serialize::serialize::Decodable for std::collections::hash::map::HashMap<K, V, S>>::decode::{{closure}}::{{closure}}
  24: serialize::serialize::Decoder::read_map_elt_val
  25: serialize::collection_impls::<impl serialize::serialize::Decodable for std::collections::hash::map::HashMap<K, V, S>>::decode::{{closure}}
  26: serialize::serialize::Decoder::read_map
  27: serialize::collection_impls::<impl serialize::serialize::Decodable for std::collections::hash::map::HashMap<K, V, S>>::decode
  28: core::ops::FnOnce::call_once
  29: serialize::serialize::Decoder::read_struct_field
  30: <rustc::lint::table::LintTable as serialize::serialize::Decodable>::decode::{{closure}}
  31: serialize::serialize::Decoder::read_struct
  32: <rustc::lint::table::LintTable as serialize::serialize::Decodable>::decode
  33: core::ops::FnOnce::call_once
  34: serialize::serialize::Decoder::read_struct_field
  35: <rustc::ty::context::TypeckTables<'tcx> as serialize::serialize::Decodable>::decode::{{closure}}
  36: serialize::serialize::Decoder::read_struct
  37: <rustc::ty::context::TypeckTables<'tcx> as serialize::serialize::Decodable>::decode
  38: rustc_metadata::decoder::<impl rustc_metadata::schema::Lazy<T>>::decode
  39: rustc_metadata::decoder::<impl rustc_metadata::cstore::CrateMetadata>::item_body_tables
  40: rustc_metadata::cstore_impl::provide::typeck_tables_of
  41: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get_with::{{closure}}
  42: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  43: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get_with
  44: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  45: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  46: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
  47: rustc_const_eval::eval::const_eval
  48: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get_with::{{closure}}
  49: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  50: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get_with
  51: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get
  52: rustc::ty::maps::TyCtxtAt::const_eval
  53: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::const_eval
  54: rustc::ty::AdtDef::discriminants::{{closure}}
  55: core::ops::impls::<impl core::ops::FnOnce<A> for &'a mut F>::call_once
  56: <core::option::Option<T>>::map
  57: <core::iter::Map<I, F> as core::iter::iterator::Iterator>::next
  58: rustc::ty::layout::Layout::compute_uncached
  59: rustc::ty::util::<impl rustc::ty::TyS<'tcx>>::layout
  60: rustc::ty::layout::Layout::compute_uncached::{{closure}}
  61: core::ops::impls::<impl core::ops::FnOnce<A> for &'a mut F>::call_once
  62: <core::option::Option<T>>::map
  63: <core::iter::Map<I, F> as core::iter::iterator::Iterator>::next
  64: <<core::result::Result<V, E> as core::iter::traits::FromIterator<core::result::Result<A, E>>>::from_iter::Adapter<Iter, E> as core::iter::iterator::Iterator>::next
  65: <&'a mut I as core::iter::iterator::Iterator>::next
  66: <collections::vec::Vec<T> as collections::vec::SpecExtend<T, I>>::from_iter
  67: <collections::vec::Vec<T> as core::iter::traits::FromIterator<T>>::from_iter
  68: <core::result::Result<V, E> as core::iter::traits::FromIterator<core::result::Result<A, E>>>::from_iter
  69: core::iter::iterator::Iterator::collect
  70: rustc::ty::layout::Layout::compute_uncached
  71: rustc::ty::util::<impl rustc::ty::TyS<'tcx>>::layout
  72: <rustc_lint::types::VariantSizeDifferences as rustc::lint::LateLintPass<'a, 'tcx>>::check_item::{{closure}}
  73: rustc::infer::InferCtxtBuilder::enter::{{closure}}
  74: rustc::ty::context::tls::enter::{{closure}}
  75: <std::thread::local::LocalKey<T>>::with
  76: rustc::ty::context::tls::enter
  77: rustc::ty::context::GlobalCtxt::enter_local
  78: rustc::infer::InferCtxtBuilder::enter
  79: <rustc_lint::types::VariantSizeDifferences as rustc::lint::LateLintPass<'a, 'tcx>>::check_item
  80: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item::{{closure}}
  81: rustc::lint::context::LintContext::with_lint_attrs
  82: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  83: rustc::hir::intravisit::Visitor::visit_nested_item
  84: rustc::hir::intravisit::walk_mod
  85: <rustc::lint::context::LateContext<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_mod
  86: rustc::hir::intravisit::walk_crate
  87: rustc::lint::context::check_crate::{{closure}}
  88: rustc::lint::context::LintContext::with_lint_attrs
  89: rustc::lint::context::check_crate
  90: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::{{closure}}

frewsxcv added a commit to frewsxcv/rust that referenced this issue May 23, 2017
…t-id, r=nikomatsakis

Refactor: Move the mutable parts out of LintStore. Fix rust-lang#42007.

* rust-lang#42007 happens because the `Session` `LintStore` is emptied when linting.
* The `Session` `LintStore` is emptied because the checker (`Early`/`LateContext`) wants ownership.
* The checker wants ownership because it wants to mutate the pass objects and lint levels.

The ownership of the whole store is not essential, only the lint levels and pass objects need to be owned. Therefore, these parts are extracted out of the `LintStore` into a separate structure `LintSession`. The "check crates" methods can operate on `&mut LintSession` instead of `&mut LintStore`.

This is a minor *breaking change* for lint writers since the `LintContext` trait is changed: the `mut_lints` and `level_stack` methods are removed. But no one outside of `librustc/lint/context.rs` is using these functions, so it should be safe.
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue May 24, 2017
…t-id, r=nikomatsakis

Refactor: Move the mutable parts out of LintStore. Fix rust-lang#42007.

* rust-lang#42007 happens because the `Session` `LintStore` is emptied when linting.
* The `Session` `LintStore` is emptied because the checker (`Early`/`LateContext`) wants ownership.
* The checker wants ownership because it wants to mutate the pass objects and lint levels.

The ownership of the whole store is not essential, only the lint levels and pass objects need to be owned. Therefore, these parts are extracted out of the `LintStore` into a separate structure `LintSession`. The "check crates" methods can operate on `&mut LintSession` instead of `&mut LintStore`.

This is a minor *breaking change* for lint writers since the `LintContext` trait is changed: the `mut_lints` and `level_stack` methods are removed. But no one outside of `librustc/lint/context.rs` is using these functions, so it should be safe.
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue May 24, 2017
…t-id, r=nikomatsakis

Refactor: Move the mutable parts out of LintStore. Fix rust-lang#42007.

* rust-lang#42007 happens because the `Session` `LintStore` is emptied when linting.
* The `Session` `LintStore` is emptied because the checker (`Early`/`LateContext`) wants ownership.
* The checker wants ownership because it wants to mutate the pass objects and lint levels.

The ownership of the whole store is not essential, only the lint levels and pass objects need to be owned. Therefore, these parts are extracted out of the `LintStore` into a separate structure `LintSession`. The "check crates" methods can operate on `&mut LintSession` instead of `&mut LintStore`.

This is a minor *breaking change* for lint writers since the `LintContext` trait is changed: the `mut_lints` and `level_stack` methods are removed. But no one outside of `librustc/lint/context.rs` is using these functions, so it should be safe.
bors added a commit that referenced this issue May 25, 2017
…omatsakis

Refactor: Move the mutable parts out of LintStore. Fix #42007.

* #42007 happens because the `Session` `LintStore` is emptied when linting.
* The `Session` `LintStore` is emptied because the checker (`Early`/`LateContext`) wants ownership.
* The checker wants ownership because it wants to mutate the pass objects and lint levels.

The ownership of the whole store is not essential, only the lint levels and pass objects need to be owned. Therefore, these parts are extracted out of the `LintStore` into a separate structure `LintSession`. The "check crates" methods can operate on `&mut LintSession` instead of `&mut LintStore`.

This is a minor *breaking change* for lint writers since the `LintContext` trait is changed: the `mut_lints` and `level_stack` methods are removed. But no one outside of `librustc/lint/context.rs` is using these functions, so it should be safe.
@bors bors closed this as completed in b384b18 May 25, 2017
@Mark-Simulacrum Mark-Simulacrum added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Jun 25, 2017
@kennytm kennytm marked this as a duplicate of #43331 Jul 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly.
Projects
None yet
Development

No branches or pull requests

5 participants