Skip to content

impl_trait_in_bindings incremental compilation ICE #55234

Closed

Description

@DutchGhost

When trying to build https://github.com/DutchGhost/rust_fun/tree/dev , I found some weird ICE.

Running cargo build for a first time works fine. If then any of the files is altered, for example by inserting a newline, and then running cargo build again, results in the ICE.
cargo clean gets rid of the ICE again.

Backtrace:
thread 'main' panicked at 'index out of bounds: the len is 7275 but the index is 7275', libcore\slice\mod.rs:2454:14
stack backtrace:
   0: <std::sync::mpsc::select::Select as core::fmt::Debug>::fmt
   1: <std::path::Iter<'a> as core::convert::AsRef<std::path::Path>>::as_ref
   2: std::panicking::take_hook
   3: std::panicking::take_hook
   4: rustc::ty::structural_impls::<impl rustc::ty::context::Lift<'tcx> for rustc::mir::interpret::error::EvalError<'a>>::lift_to_tcx
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic_fmt
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::panicking::panic_bounds_check
  10: rustc::dep_graph::graph::DepGraph::assert_ignored
  11: rustc::ty::context::tls::track_diagnostic
  12: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  13: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  14: rustc::ty::context::TyCtxt::generate_borrow_of_any_match_input
  15: <unknown>
  16: rustc::ty::context::tls::track_diagnostic
  17: rustc::ty::query::on_disk_cache::OnDiskCache::load_diagnostics
  18: rustc::dep_graph::graph::DepGraph::try_mark_green
  19: rustc::dep_graph::graph::DepGraph::try_mark_green
  20: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  21: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_print_query_stack
  22: <rustc::hir::check_attr::CheckAttrVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  23: rustc::hir::Crate::impl_item
  24: rustc::hir::check_attr::check_crate
  25: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_trait_item
  26: <rustc_driver::pretty::IdentifiedAnnotation<'hir> as rustc_driver::pretty::PrinterSupport>::sess
  27: <rustc_driver::derive_registrar::Finder as rustc::hir::itemlikevisit::ItemLikeVisitor<'v>>::visit_trait_item
  28: rustc_driver::driver::compile_input
  29: rustc_driver::run_compiler
  30: <env_logger::filter::inner::Filter as core::fmt::Display>::fmt
  31: rustc_driver::run_compiler
  32: <rustc_driver::profile::trace::Query as core::fmt::Debug>::fmt
  33: <rustc_driver::CompilationFailure as core::fmt::Debug>::fmt
  34: _rust_maybe_catch_panic
  35: <unknown>
  36: rustc_driver::main
  37: <unknown>
  38: std::panicking::update_panic_count
  39: _rust_maybe_catch_panic
  40: std::rt::lang_start_internal
  41: <unknown>
  42: <unknown>
  43: BaseThreadInitThunk
  44: RtlUserThreadStart
query stack during panic:
#0 [crate_disambiguator] looking up the disambiguator a crate
end of query stack

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.31.0-nightly (78ff609d7 2018-10-19) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `rust_fun`.

Activity

  1. panicbit commented on Oct 20, 2018

    @panicbit

    I've confirmed this on nightly 2018-10-19. Turning incremental compilation off avoids the ICE.

  2. DutchGhost commented on Oct 20, 2018

    @DutchGhost
    Author

    EDIT:

    The issue seems to be in #![feature(impl_trait_in_bindings)]

    Compiling the following for a first time works fine:

    #![feature(impl_trait_in_bindings)]
    const foo: impl Fn() = || {};
    
    fn main() {}

    Then altering the file (insert a newline, a space...) and building again results in the ICE.

  3. changed the title [-]Index out of bounds ICE[/-] [+]impl_trait_in_bindings incremental compilation ICE[/+] on Oct 20, 2018
  4. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    A-incr-compArea: Incremental compilation
    on Oct 21, 2018
  5. danielhenrymantilla commented on Nov 22, 2018

    @danielhenrymantilla
    Contributor

    Was about to submit this bug, then found out about this issue.
    I guess I'll just repeat what's been said before, but maybe it's useful.

    TL,DR: When using the feature impl_trait_in_bindings, changing closure argument type annotation, leads to an Internal Compiler Error when incremental compilation is involved:

    I (successfully) compiled this code

    #![feature(impl_trait_in_bindings)] // rustc 1.32.0-nightly (0b9f19dff 2018-11-21) running on x86_64-unknown-linux-gnu
    
    fn main () {
        let _: impl Fn(i32) -> i32 = |x| x;
    }

    and then modified the code to add a type annotation on the closure argument:

    #![feature(impl_trait_in_bindings)] // rustc 1.32.0-nightly (0b9f19dff 2018-11-21) running on x86_64-unknown-linux-gnu
    
    fn main () {
        let _: impl Fn(i32) -> i32 = |x: i32| x;
    }

    I expected to see this happen: compiles successfully

    $ cargo check
        Checking temp v0.1.0 (/tmp/temp.fCUY)
        Finished dev [unoptimized + debuginfo] target(s) in 0.11s
    

    Instead, this happened: compilation crashes (even just at cargo check stage)

    $ cargo check
        Checking temp v0.1.0 (/tmp/temp.fCUY)
    thread 'main' panicked at 'index out of bounds: the len is 4129 but the index is 4129', /rustc/0b9f19dff1347e29bf4362ab5a8fab84b43023b5/src/libcore/slice/mod.rs:2453:14
    note: Run with `RUST_BACKTRACE=1` for a 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.32.0-nightly (0b9f19dff 2018-11-21) running on x86_64-unknown-linux-gnu
    
    note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin
    
    note: some of the compiler flags provided by cargo are hidden
    
    error: Could not compile `temp`.
    
    To learn more, run the command again with --verbose.
    

    Observations

    • Running cargo clean before the compilation prevents the crash.
    • It also happens the other way around (clean -> build with type annotation -> remove type annotation -> check/build again => crash)

    Meta

    $ rustc --version --verbose
    rustc 1.32.0-nightly (0b9f19dff 2018-11-21)
    binary: rustc
    commit-hash: 0b9f19dff1347e29bf4362ab5a8fab84b43023b5
    commit-date: 2018-11-21
    host: x86_64-unknown-linux-gnu
    release: 1.32.0-nightly
    LLVM version: 8.0
    

    Backtrace:

    $ cargo check
       Compiling temp v0.1.0 (/tmp/temp.fCUY)
    thread 'main' panicked at 'index out of bounds: the len is 4792 but the index is 4792', /rustc/0b9f19dff1347e29bf4362ab5a8fab84b43023b5/src/libcore/slice/mod.rs:2447:10
    stack backtrace:
       0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
                 at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
       1: std::sys_common::backtrace::_print
                 at libstd/sys_common/backtrace.rs:71
       2: std::panicking::default_hook::{{closure}}
                 at libstd/sys_common/backtrace.rs:59
                 at libstd/panicking.rs:211
       3: std::panicking::default_hook
                 at libstd/panicking.rs:227
       4: rustc::util::common::panic_hook
       5: std::panicking::rust_panic_with_hook
                 at libstd/panicking.rs:480
       6: std::panicking::continue_panic_fmt
                 at libstd/panicking.rs:390
       7: rust_begin_unwind
                 at libstd/panicking.rs:325
       8: core::panicking::panic_fmt
                 at libcore/panicking.rs:77
       9: core::panicking::panic_bounds_check
                 at libcore/panicking.rs:59
      10: rustc::dep_graph::graph::DepGraph::node_color
      11: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_mark_green_and_read
      12: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
      13: <rustc::ty::layout::LayoutCx<'tcx, rustc::ty::context::TyCtxt<'a, 'tcx, 'tcx>> as rustc_target::abi::LayoutOf>::layout_of
      14: <rustc_codegen_llvm::context::CodegenCx<'ll, 'tcx> as rustc_target::abi::LayoutOf>::layout_of
      15: rustc_codegen_llvm::callee::get_fn
      16: rustc_codegen_ssa::base::maybe_create_entry_wrapper::create_entry_fn
      17: rustc_codegen_ssa::base::maybe_create_entry_wrapper
      18: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
      19: rustc::dep_graph::graph::DepGraph::with_task
      20: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::compile_codegen_unit
      21: rustc_codegen_ssa::base::codegen_crate
      22: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
      23: rustc::util::common::time
      24: rustc_driver::driver::phase_4_codegen
      25: rustc_driver::driver::compile_input::{{closure}}
      26: rustc::ty::context::tls::enter_context
      27: <std::thread::local::LocalKey<T>>::with
      28: rustc::ty::context::TyCtxt::create_and_enter
      29: rustc_driver::driver::compile_input
      30: rustc_driver::run_compiler_with_pool
      31: <scoped_tls::ScopedKey<T>>::set
      32: rustc_driver::run_compiler
      33: syntax::with_globals
      34: __rust_maybe_catch_panic
                 at libpanic_unwind/lib.rs:102
      35: rustc_driver::run
      36: rustc_driver::main
      37: std::rt::lang_start::{{closure}}
      38: std::panicking::try::do_call
                 at libstd/rt.rs:59
                 at libstd/panicking.rs:310
      39: __rust_maybe_catch_panic
                 at libpanic_unwind/lib.rs:102
      40: std::rt::lang_start_internal
                 at libstd/panicking.rs:289
                 at libstd/panic.rs:398
                 at libstd/rt.rs:58
      41: main
      42: __libc_start_main
      43: <unknown>
    query stack during panic:
    end of query stack
    
    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.32.0-nightly (0b9f19dff 2018-11-21) running on x86_64-unknown-linux-gnu
    
    note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin
    
    note: some of the compiler flags provided by cargo are hidden
    
    error: Could not compile `temp`.
    
    To learn more, run the command again with --verbose.
    
  6. added
    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
    on Mar 29, 2019
  7. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-bugCategory: This is a bug.
    on Mar 29, 2019
  8. added
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    on Jul 28, 2019
  9. gizmondo commented on Mar 25, 2020

    @gizmondo
    Contributor

    @DutchGhost, it seems this issue isn't reproducible anymore.

  10. DutchGhost commented on Mar 25, 2020

    @DutchGhost
    Author

    Closing since it isn't reproducable any longer.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-incr-compArea: Incremental compilationC-bugCategory: This is a bug.F-impl_trait_in_bindings`#![feature(impl_trait_in_bindings)]`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.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions