Skip to content

Nightly ICEs trying to normalize during a cast #73747

Closed

Description

@BlackHoleFox

On the latest nightly (2020-06-25), a small usage of the WinRT crate causes an ICE when trying to compile even a small example. I confirmed that the past week of nightly releases compile fine before the latest. On the latest stable (1.44.1) this compiles just fine as expected.

Code

Cargo.toml:

[dependencies]
winrt = "0.7.0"
use winrt::*;

use windows::security::credentials::ui::UserConsentVerifier;

import!(
    dependencies
        os
    types
        windows::security::credentials::ui::UserConsentVerifier
);

fn main() {
    let _ = UserConsentVerifier::check_availability_async().unwrap();
}

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (50fc24d8a 2020-06-25)
binary: rustc
commit-hash: 50fc24d8a172a853b5dfe40702d6550e3b8562ba
commit-date: 2020-06-25
host: x86_64-pc-windows-msvc
release: 1.46.0-nightly
LLVM version: 10.0

Error output

error: internal compiler error: src\librustc_traits\normalize_erasing_regions.rs:37:32: could not fully normalize `std::ptr::NonNull<std::ptr::NonNull<<windows::foundation::IAsyncOperation<TResult> as winrt::com::interface::ComInterface>::VTable>>`

thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:916:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.46.0-nightly (50fc24d8a 2020-06-25) running on x86_64-pc-windows-msvc

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

query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `std::ptr::NonNull<std::ptr::NonNull<<windows::foundation::IAsyncOperation<TResult> as winrt::com::interface::ComInterface>::VTable>>`
#1 [lint_mod] linting module `windows::foundation`
#2 [analysis] running analysis passes on this crate
end of query stack
Backtrace

thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:916:9
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: <std::io::IoSliceMut as core::fmt::Debug>::fmt
   3: std::panicking::take_hook
   4: std::panicking::take_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: <rustc_errors::styled_buffer::StyledBuffer as core::fmt::Debug>::fmt
   8: rustc_errors::HandlerInner::err_count
   9: rustc_errors::Handler::bug
  10: rustc_middle::util::bug::bug_fmt
  11: rustc_middle::ty::walk::<impl rustc_middle::ty::subst::GenericArg>::walk_shallow
  12: rustc_middle::ty::walk::<impl rustc_middle::ty::subst::GenericArg>::walk_shallow
  13: rustc_middle::util::bug::bug_fmt
  14: rustc_middle::util::bug::bug_fmt
  15: <rustc_traits::chalk::db::RustIrDatabase as chalk_solve::RustIrDatabase<rustc_middle::traits::chalk::RustInterner>>::hidden_opaque_type
  16: <rustc_traits::chalk::lowering::ParamsSubstitutor as rustc_middle::ty::fold::TypeFolder>::fold_region
  17: <rustc_middle::ty::query::Query as rustc_data_structures::stable_hasher::HashStable<rustc_middle::ich::hcx::StableHashingContext>>::hash_stable
  18: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::debug_node
  19: <rustc_middle::ty::binding::BindingMode as rustc_middle::ty::context::Lift>::lift_to_tcx
  20: <rustc_middle::ty::subst::UserSubsts as core::fmt::Debug>::fmt
  21: <rustc_middle::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_middle::ty::fold::TypeFolder>::fold_ty
  22: <rustc_lint::types::TypeLimits as rustc_lint::passes::LateLintPass>::check_expr
  23: <rustc_lint::types::TypeLimits as rustc_lint::passes::LateLintPass>::check_expr
  24: <rustc_lint::types::ImproperCTypesVisitor::check_for_opaque_ty::ProhibitOpaqueTypes as rustc_middle::ty::fold::TypeVisitor>::visit_ty
  25: <rustc_lint::types::ImproperCTypesVisitor::check_for_opaque_ty::ProhibitOpaqueTypes as rustc_middle::ty::fold::TypeVisitor>::visit_ty
  26: <rustc_lint::BuiltinCombinedModuleLateLintPass as rustc_lint::passes::LateLintPass>::check_fn
  27: rustc_lint::late::unerased_lint_store
  28: rustc_lint::builtin::ClashingExternDecl::get_lints
  29: <rustc_lint::array_into_iter::ArrayIntoIter as rustc_session::lint::LintPass>::name
  30: rustc_lint::builtin::ClashingExternDecl::get_lints
  31: <rustc_lint::array_into_iter::ArrayIntoIter as rustc_session::lint::LintPass>::name
  32: <rustc_lint::late::LateLintPassObjects as rustc_session::lint::LintPass>::name
  33: <rustc_interface::util::ReplaceBodyWithLoop as rustc_ast::mut_visit::MutVisitor>::visit_mac
  34: <rustc_interface::util::ReplaceBodyWithLoop as rustc_ast::mut_visit::MutVisitor>::visit_mac
  35: <rustc_interface::util::ReplaceBodyWithLoop as rustc_ast::mut_visit::MutVisitor>::visit_mac
  36: <rustc_interface::util::ReplaceBodyWithLoop as rustc_ast::mut_visit::MutVisitor>::visit_mac
  37: <rustc_interface::util::ReplaceBodyWithLoop as rustc_ast::mut_visit::MutVisitor>::visit_mac
  38: <rustc_interface::util::ReplaceBodyWithLoop as rustc_ast::mut_visit::MutVisitor>::visit_mac
  39: <rustc_interface::util::ReplaceBodyWithLoop as rustc_ast::mut_visit::MutVisitor>::visit_mac
  40: <rustc_interface::util::ReplaceBodyWithLoop as rustc_ast::mut_visit::MutVisitor>::visit_mac
  41: rustc_interface::passes::QueryContext::print_stats
  42: <rustc_driver::args::Error as core::fmt::Debug>::fmt
  43: <rustc_metadata::foreign_modules::Collector as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_impl_item
  44: rustc_driver::pretty::print_after_hir_lowering
  45: <i32 as petgraph::matrix_graph::Zero>::zero
  46: rustc_driver::pretty::print_after_hir_lowering
  47: <rustc_driver::args::Error as core::fmt::Debug>::fmt
  48: <rustc_metadata::foreign_modules::Collector as rustc_hir::itemlikevisit::ItemLikeVisitor>::visit_impl_item
  49: <rustc_driver::args::Error as core::fmt::Debug>::fmt
  50: <rustc_driver::DEFAULT_HOOK as core::ops::deref::Deref>::deref
  51: <i32 as petgraph::matrix_graph::Zero>::zero
  52: std::sys::windows::thread::Thread::new
  53: BaseThreadInitThunk
  54: RtlUserThreadStart

Activity

  1. added
    C-bugCategory: This is a bug.
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jun 26, 2020
  2. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jun 26, 2020
  3. added
    E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc
    E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
    on Jun 26, 2020
  4. LeSeulArtichaut commented on Jun 26, 2020

    @LeSeulArtichaut
    Contributor

    Let’s try to find an MCVE. I’d also like to find the culprit PR, which shouldn’t take too long since we know in which nightly this regressed.

    @rustbot ping cleanup

  5. rustbot commented on Jun 26, 2020

    @rustbot
    Collaborator

    Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
    "Cleanup ICE-breaking candidate". In case it's useful, here are some
    instructions for tackling these sorts of bugs. Maybe take a look?
    Thanks! <3

    cc @AminArria @camelid @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke

  6. Dylan-DPC-zz commented on Jun 26, 2020

    @Dylan-DPC-zz

    Just tried this out locally as well and can confirm the ICE happens.. time to dig in ..

  7. spastorino commented on Jun 26, 2020

    @spastorino
    Member

    @rustbot ping windows

  8. rustbot commented on Jun 26, 2020

    @rustbot
    Collaborator

    Hey Windows Group! This bug has been identified as a good "Windows candidate".
    In case it's useful, here are some instructions for tackling these sorts of
    bugs. Maybe take a look?
    Thanks! <3

    cc @arlosi @danielframpton @gdr-at-ms @kennykerr @luqmana @lzybkr @retep998 @rylev @sivadeilra @spastorino

  9. Avi-D-coder commented on Jun 27, 2020

    @Avi-D-coder
    Contributor

    Similar ICE

    unsafe {
        ptr::swap(
            ts.gc_arenas_full as *mut _ as *mut HashSet<*mut u8>,
            &mut ts.condemned_arenas,
        )
    }

    The correct error from nightly-2020-06-18 (There may be newer nightlys before the regesion)

     error[E0605]: non-primitive cast: `std::collections::HashSet<*mut arena::HeaderUnTyped>` as `*mut _`
       --> src/gc_logic.rs:705:25
        |
    705 |                         ts.gc_arenas_full as *mut _ as *mut HashSet<*mut u8>,
        |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
    
    error[E0605]: non-primitive cast: `std::collections::HashSet<*mut arena::HeaderUnTyped>` as `*mut _`
       --> src/gc_logic.rs:705:25
        |
    705 |                         ts.gc_arenas_full as *mut _ as *mut HashSet<*mut u8>,
        |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait
    
    error: aborting due to previous error; 1 warning emitted
    
    ICE / Backtrace

    error: internal compiler error: src/librustc_middle/ich/impls_ty.rs:167:9: ty::TyKind::hash_stable() - can't hash a TyVid _#649t.
    
    thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:916:9
    stack backtrace:
       0: backtrace::backtrace::libunwind::trace
                 at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
       1: backtrace::backtrace::trace_unsynchronized
                 at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
       2: std::sys_common::backtrace::_print_fmt
                 at src/libstd/sys_common/backtrace.rs:78
       3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
                 at src/libstd/sys_common/backtrace.rs:59
       4: core::fmt::write
                 at src/libcore/fmt/mod.rs:1076
       5: std::io::Write::write_fmt
                 at src/libstd/io/mod.rs:1537
       6: std::sys_common::backtrace::_print
                 at src/libstd/sys_common/backtrace.rs:62
       7: std::sys_common::backtrace::print
                 at src/libstd/sys_common/backtrace.rs:49
       8: std::panicking::default_hook::{{closure}}
                 at src/libstd/panicking.rs:198
       9: std::panicking::default_hook
                 at src/libstd/panicking.rs:217
      10: rustc_driver::report_ice
      11: std::panicking::rust_panic_with_hook
                 at src/libstd/panicking.rs:524
      12: std::panicking::begin_panic
      13: rustc_errors::HandlerInner::bug
      14: rustc_errors::Handler::bug
      15: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
      16: rustc_middle::ty::context::tls::with_opt::{{closure}}
      17: rustc_middle::ty::context::tls::with_opt
      18: rustc_middle::util::bug::opt_span_bug_fmt
      19: rustc_middle::util::bug::bug_fmt
      20: rustc_middle::ich::impls_ty::<impl rustc_data_structures::stable_hasher::HashStable<rustc_middle::ich::hcx::StableHashingContext> for rustc_middle::ty::sty::TyVid>::hash_stable
      21: rustc_middle::ty::sty::_DERIVE_rustc_data_structures_stable_hasher_HashStable_rustc_middle_ich_StableHashingContext_ctx_FOR_InferTy::<impl rustc_data_structures::stable_hasher::HashStable<rustc_middle::ich::hcx::StableHashingContext> for rustc_middle::ty::sty::InferTy>::hash_stable
      22: rustc_middle::ty::sty::_DERIVE_rustc_data_structures_stable_hasher_HashStable_rustc_middle_ich_StableHashingContext_ctx_FOR_TyKind::<impl rustc_data_structures::stable_hasher::HashStable<rustc_middle::ich::hcx::StableHashingContext> for rustc_middle::ty::sty::TyKind>::hash_stable
      23: <T as rustc_query_system::dep_graph::dep_node::DepNodeParams<Ctxt>>::to_fingerprint
      24: rustc_query_system::query::plumbing::get_query_impl
      25: rustc_typeck::check::cast::CastCheck::check
      26: rustc_typeck::check::FnCtxt::check_casts
      27: rustc_middle::ty::context::GlobalCtxt::enter_local
      28: rustc_typeck::check::typeck_tables_of
      29: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_tables_of>::compute
      30: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
      31: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
      32: rustc_data_structures::stack::ensure_sufficient_stack
      33: rustc_query_system::query::plumbing::get_query_impl
      34: rustc_query_system::query::plumbing::ensure_query_impl
      35: rustc_typeck::check::typeck_item_bodies
      36: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
      37: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
      38: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
      39: rustc_data_structures::stack::ensure_sufficient_stack
      40: rustc_query_system::query::plumbing::get_query_impl
      41: rustc_typeck::check_crate
      42: rustc_interface::passes::analysis
      43: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
      44: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
      45: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
      46: rustc_data_structures::stack::ensure_sufficient_stack
      47: rustc_query_system::query::plumbing::get_query_impl
      48: rustc_middle::ty::context::tls::enter_global
      49: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
      50: rustc_span::with_source_map
      51: rustc_interface::interface::run_compiler_in_existing_thread_pool
      52: scoped_tls::ScopedKey<T>::set
    note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

  10. 15 remaining items

  11. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jul 14, 2020
  12. self-assigned this
    on Jul 14, 2020
  13. added a commit that references this issue on Jul 14, 2020
    dbe7ed3
  14. removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on Jul 14, 2020
  15. pnkfelix commented on Jul 16, 2020

    @pnkfelix
    Contributor

    reopening; the next beta was cut before this landed in master, so this ended up being a regression-from-stable-to-beta

  16. added and removed on Jul 16, 2020
  17. pnkfelix commented on Jul 16, 2020

    @pnkfelix
    Contributor

    however, I also think the bug is under control now that the PR has landed on nightly. Reprioritizing as P-high.

  18. added
    P-highHigh priority
    and removed on Jul 16, 2020
  19. emilyalbini commented on Aug 21, 2020

    @emilyalbini
    Member

    The fix was backported, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.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