Skip to content

Possible incremental compilation bug #92485

Description

@sofia-m-a

I have no idea where to start with minimizing this, it's a fairly tightly-coupled Bevy game codebase.

I can provide other code as needed. The bug was reproducible for a while, but after removing some dead code, it builds just fine, even if I go back to the code as it was when the error happened.

Here is the function that it panics on:

Code

fn main() {
    App::new()
        .insert_resource(WgpuOptions {
            limits: WgpuLimits {
                max_texture_array_layers: 2048,
                ..Default::default()
            },
            ..Default::default()
        })
        .add_state(GameState::Splash)
        .add_plugins(DefaultPlugins)
        //.add_plugin(AnimationPlugin)
        //.add_plugin(RapierPhysicsPlugin::<NoUserData>::default())
        .add_plugin(LetterboxCameraPlugin)
        .add_system_set(SystemSet::on_enter(GameState::Splash).with_system(setup_sprites))
        .add_system_set(SystemSet::on_update(GameState::Splash).with_system(update_clear_colour))
        .add_system_set(
            SystemSet::on_enter(GameState::Level)
                .with_system(setup)
                .with_system(setup_player),
        )
        .add_system_set(
            SystemSet::on_update(GameState::Level)
                .with_system(keyboard_input_system)
                .with_system(chunk_load_unload),
        )
        .add_system(set_texture_filters_to_nearest)
        .run();
}

Meta

rustc --version --verbose:

rustc 1.59.0-nightly (c09a9529c 2021-12-23)
binary: rustc
commit-hash: c09a9529c51cde41c1101e56049d418edb07bf71
commit-date: 2021-12-23
host: x86_64-unknown-linux-gnu
release: 1.59.0-nightly
LLVM version: 13.0.0

Error output

warning: unused import: `SHEET_H`
 --> src/map/brushes.rs:1:21
  |
1 | use crate::assets::{SHEET_H, SHEET_W};
  |                     ^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `Vec2`
 --> src/map/map.rs:8:25
  |
8 |     math::{IVec2, Rect, Vec2, Vec3},
  |                         ^^^^

warning: unused imports: `SHEET_H`, `SHEET_W`, `TILE_SIZE`
  --> src/main.rs:12:66
   |
12 |     set_texture_filters_to_nearest, setup_sprites, SpriteAssets, SHEET_H, SHEET_W, TILE_SIZE,
   |                                                                  ^^^^^^^  ^^^^^^^  ^^^^^^^^^

warning: unused variable: `commands`
  --> src/main.rs:63:9
   |
63 |     mut commands: Commands,
   |         ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_commands`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `graphics`
   --> src/main.rs:104:5
    |
104 |     graphics: Res<SpriteAssets>,
    |     ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_graphics`

warning: unused variable: `graphics`
   --> src/main.rs:129:41
    |
129 | fn setup_player(mut commands: Commands, graphics: Res<SpriteAssets>) {
    |                                         ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_graphics`

warning: variable does not need to be mutable
  --> src/main.rs:63:5
   |
63 |     mut commands: Commands,
   |     ----^^^^^^^^
   |     |
   |     help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

warning: path statement with no effect
  --> src/camera.rs:35:5
   |
35 |     center_mean;
   |     ^^^^^^^^^^^^
   |
   = note: `#[warn(path_statements)]` on by default
Backtrace

thread 'rustc' panicked at 'index out of bounds: the len is 141 but the index is 145', compiler/rustc_query_impl/src/on_disk_cache.rs:712:18
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c09a9529c51cde41c1101e56049d418edb07bf71/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/c09a9529c51cde41c1101e56049d418edb07bf71/library/core/src/panicking.rs:107:14
   2: core::panicking::panic_bounds_check
             at /rustc/c09a9529c51cde41c1101e56049d418edb07bf71/library/core/src/panicking.rs:75:5
   3: <rustc_span::span_encoding::Span as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
   4: <rustc_middle::ty::VariantDef as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
   5: <rustc_query_impl::on_disk_cache::CacheDecoder as rustc_serialize::serialize::Decoder>::read_seq::<alloc::vec::Vec<rustc_middle::ty::VariantDef>, <alloc::vec::Vec<rustc_middle::ty::VariantDef> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>
   6: <rustc_middle::ty::adt::AdtDef as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
   7: <rustc_middle::ty::sty::TyKind as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
   8: <&rustc_middle::ty::TyS as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
   9: <&rustc_middle::ty::TyS as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode
  10: <rustc_query_impl::on_disk_cache::CacheDecoder as rustc_serialize::serialize::Decoder>::read_map::<std::collections::hash::map::HashMap<rustc_hir::hir_id::ItemLocalId, &rustc_middle::ty::TyS, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>, <std::collections::hash::map::HashMap<rustc_hir::hir_id::ItemLocalId, &rustc_middle::ty::TyS, core::hash::BuildHasherDefault<rustc_hash::FxHasher>> as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}>
  11: <rustc_middle::ty::context::TypeckResults as rustc_serialize::serialize::Decodable<rustc_query_impl::on_disk_cache::CacheDecoder>>::decode::{closure#0}
  12: <rustc_query_impl::on_disk_cache::OnDiskCache>::try_load_query_result::<&rustc_middle::ty::context::TypeckResults>
  13: rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults>
  14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::ty::context::TypeckResults>>
  15: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  16: <rustc_passes::liveness::IrMaps as rustc_hir::intravisit::Visitor>::visit_body
  17: rustc_hir::intravisit::walk_item::<rustc_passes::liveness::IrMaps>
  18: <rustc_middle::hir::map::Map>::visit_item_likes_in_module::<rustc_hir::intravisit::DeepVisitor<rustc_passes::liveness::IrMaps>>
  19: rustc_passes::liveness::check_mod_liveness
  20: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, ()>
  21: rustc_data_structures::stack::ensure_sufficient_stack::<((), rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::LocalDefId, ()>::{closure#3}>
  22: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, ()>>
  23: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::check_mod_liveness, rustc_query_impl::plumbing::QueryCtxt>
  24: <core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::passes::analysis::{closure#1}::{closure#1}> as core::ops::function::FnOnce<()>>::call_once
  25: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#1}>
  26: rustc_interface::passes::analysis
  27: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>
  28: rustc_data_structures::stack::ensure_sufficient_stack::<(core::result::Result<(), rustc_errors::ErrorReported>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>::{closure#3}>
  29: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorReported>>>
  30: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  31: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorReported>>
  32: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
  33: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  34: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>
  35: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.59.0-nightly (c09a9529c 2021-12-23) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z share-generics=y -C opt-level=1 -C embed-bitcode=no -C debuginfo=2 -C debug-assertions=on -C linker=clang -C incremental -C link-arg=-fuse-ld=lld --crate-type bin

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

query stack during panic:
#0 [typeck] type-checking `main`
#1 [check_mod_liveness] checking liveness of variables in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack

Activity

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

    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.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions