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

Nightly ICEs trying to normalize during a cast #73747

Closed
BlackHoleFox opened this issue Jun 26, 2020 · 18 comments · Fixed by #74340
Closed

Nightly ICEs trying to normalize during a cast #73747

BlackHoleFox opened this issue Jun 26, 2020 · 18 comments · Fixed by #74340
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@BlackHoleFox
Copy link
Contributor

BlackHoleFox commented Jun 26, 2020

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

@BlackHoleFox BlackHoleFox 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 Jun 26, 2020
@jonas-schievink jonas-schievink added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Jun 26, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jun 26, 2020
@LeSeulArtichaut LeSeulArtichaut added E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Jun 26, 2020
@LeSeulArtichaut
Copy link
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

@rustbot rustbot added the ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections label Jun 26, 2020
@rustbot
Copy link
Collaborator

rustbot commented Jun 26, 2020

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

@Dylan-DPC-zz
Copy link

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

@spastorino
Copy link
Member

@rustbot ping windows

@rustbot
Copy link
Collaborator

rustbot commented Jun 26, 2020

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

@rustbot rustbot added the O-windows Operating system: Windows label Jun 26, 2020
@Avi-D-coder
Copy link
Contributor

Avi-D-coder commented Jun 27, 2020

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.

@spastorino
Copy link
Member

spastorino commented Jul 1, 2020

Prioritized this one as P-critical as per Zulip discussion

@spastorino spastorino added P-critical Critical priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jul 1, 2020
@pnkfelix pnkfelix self-assigned this Jul 2, 2020
@pnkfelix
Copy link
Member

pnkfelix commented Jul 2, 2020

This ICE went away between nightly-2020-06-28 and nightly-2020-06-29.

Bisecting further now.

@pnkfelix
Copy link
Member

pnkfelix commented Jul 2, 2020

searched nightlies: from nightly-2020-06-28 to nightly-2020-06-29
regressed nightly: nightly-2020-06-29
searched commits: from 394e1b4 to 2f517ce
regressed commit: 25687ca

bisected with cargo-bisect-rustc v0.5.2

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

cargo bisect-rustc success --start 2020-06-28 --end 2020-06-29 --access github --preserve

@LeSeulArtichaut LeSeulArtichaut removed the E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc label Jul 2, 2020
@connorskees
Copy link
Contributor

connorskees commented Jul 12, 2020

Minified,

#[repr(transparent)]
struct NonNullRawComPtr<T: ComInterface> {
    inner: std::ptr::NonNull<<T as ComInterface>::VTable>,
}

trait ComInterface {
    type VTable;
}

extern "C" fn invoke<T: ComInterface>(_: Option<NonNullRawComPtr<T>>) {}

With the message,

error: internal compiler error: src\librustc_traits\normalize_erasing_regions.rs:37:32: could not fully normalize `std::ptr::NonNull<<T as 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

@pnkfelix
Copy link
Member

@connorskees 's MCVE shows that this problem is not windows-specific. Updating labels accordingly.

@pnkfelix pnkfelix removed O-windows Operating system: Windows ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Jul 14, 2020
@pnkfelix
Copy link
Member

Also, it looks to me like this MCVE still reproduces on the current nightly. (So something must have been off with my earlier bisection that claimed it was fixed. The original problem has been tricky for me to consistently reproduce.)

@pnkfelix
Copy link
Member

pnkfelix commented Jul 14, 2020

On the plus side, I was able to run cargo-bisect-rustc on @connorskees 's MCVE (to identify the point where it regressed), and got this result:

searched nightlies: from nightly-2020-06-22 to nightly-2020-07-14
regressed nightly: nightly-2020-06-26
searched commits: from 67100f6 to 50fc24d
regressed commit: 9f3c96b

bisected with cargo-bisect-rustc v0.5.2

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc 

@LeSeulArtichaut
Copy link
Contributor

Culprit is likely #72700? cc @davidtwco

@LeSeulArtichaut LeSeulArtichaut added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jul 14, 2020
@davidtwco davidtwco self-assigned this Jul 14, 2020
@pnkfelix
Copy link
Member

@pnkfelix pnkfelix removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jul 14, 2020
@bors bors closed this as completed in dbe7ed3 Jul 14, 2020
@pnkfelix
Copy link
Member

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

@pnkfelix pnkfelix reopened this Jul 16, 2020
@pnkfelix pnkfelix added regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Jul 16, 2020
@pnkfelix
Copy link
Member

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

@pnkfelix pnkfelix added P-high High priority and removed P-critical Critical priority labels Jul 16, 2020
@pietroalbini
Copy link
Member

The fix was backported, closing.

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) ❄️ P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.