Skip to content

ICE when compiling code #84831

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
bioglaze opened this issue May 2, 2021 · 11 comments · Fixed by #84913
Closed

ICE when compiling code #84831

bioglaze opened this issue May 2, 2021 · 11 comments · Fixed by #84913
Assignees
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) C-bug Category: This is a bug. 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

@bioglaze
Copy link

bioglaze commented May 2, 2021

Crashes when running cargo build.

Code

// Cargo.toml dependency: ash = "0.32"

pub use ash::version::{DeviceV1_0, EntryV1_0, InstanceV1_0};

pub struct GfxDevice
{
    pub physical_device : vk::PhysicalDevice,
    pub vulkan_device : ash::version::<Type as InstanceV1_0>::Device
}


fn main() {
    println!("Hello, world!");
}

Meta

rustc --version --verbose:

rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-unknown-linux-gnu
release: 1.51.0
LLVM version: 11.0.1

Error output

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_metadata/src/rmeta/decoder.rs:900:54

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

query stack during panic:
#0 [generics_of] computing generics of `ash::version`
#1 [opt_const_param_of] computing the optional const parameter of `GfxDevice::vulkan_device::{constant#0}`
#2 [typeck] type-checking `GfxDevice::vulkan_device::{constant#0}`
#3 [typeck_item_bodies] type-checking all item bodies
#4 [analysis] running analysis passes on this crate
end of query stack

Backtrace

   0: rust_begin_unwind
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/panicking.rs:50:5
   3: rustc_metadata::rmeta::decoder::<impl rustc_metadata::creader::CrateMetadataRef>::get_generics
   4: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::generics_of
   5: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::generics_of>::compute
   6: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
   7: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
   8: rustc_data_structures::stack::ensure_sufficient_stack
   9: rustc_query_system::query::plumbing::force_query_with_job
  10: rustc_query_system::query::plumbing::get_query_impl
  11: rustc_typeck::collect::type_of::opt_const_param_of
  12: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::opt_const_param_of>::compute
  13: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  14: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  15: rustc_data_structures::stack::ensure_sufficient_stack
  16: rustc_query_system::query::plumbing::force_query_with_job
  17: rustc_query_system::query::plumbing::get_query_impl
  18: rustc_typeck::check::typeck
  19: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute
  20: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  21: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  22: rustc_data_structures::stack::ensure_sufficient_stack
  23: rustc_query_system::query::plumbing::force_query_with_job
  24: rustc_query_system::query::plumbing::get_query_impl
  25: rustc_query_system::query::plumbing::ensure_query_impl
  26: rustc_typeck::check::typeck_item_bodies
  27: 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
  28: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  29: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  30: rustc_data_structures::stack::ensure_sufficient_stack
  31: rustc_query_system::query::plumbing::force_query_with_job
  32: rustc_query_system::query::plumbing::get_query_impl
  33: rustc_typeck::check_crate
  34: rustc_interface::passes::analysis
  35: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  36: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  37: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  38: rustc_data_structures::stack::ensure_sufficient_stack
  39: rustc_query_system::query::plumbing::force_query_with_job
  40: rustc_query_system::query::plumbing::get_query_impl
  41: rustc_interface::passes::QueryContext::enter
  42: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  43: rustc_span::with_source_map
  44: rustc_interface::interface::create_compiler_and_run
  45: rustc_span::with_session_globals

@bioglaze bioglaze 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 May 2, 2021
@hellow554
Copy link
Contributor

hellow554 commented May 3, 2021

Regression in nightly-2020-10-28 between fd54259...07e968b

Does occur since 1.49

@rustbot modify labels: A-meta regression-from-stable-to-stable

@rustbot rustbot added A-meta Area: Issues & PRs about the rust-lang/rust repository itself 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 May 3, 2021
@hameerabbasi
Copy link
Contributor

This is an error->ICE case, with a nice error as well.

full build output
$ cargo build
   Compiling bisect v0.1.0 (/home/habbasi/bisect)
error: expected one of `,` or `>`, found keyword `as`
 --> src/lib.rs:6:45
  |
6 |     pub vulkan_device : ash::version::<Type as InstanceV1_0>::Device
  |                                             ^^ expected one of `,` or `>`
  |
help: expressions must be enclosed in braces to be used as const generic arguments
  |
6 |     pub vulkan_device : ash::version::<{ Type as InstanceV1_0 }>::Device
  |                                        ^                      ^

error[E0433]: failed to resolve: use of undeclared crate or module `vk`
 --> src/lib.rs:5:27
  |
5 |     pub physical_device : vk::PhysicalDevice,
  |                           ^^ use of undeclared crate or module `vk`

error[E0412]: cannot find type `Device` in module `ash::version`
 --> src/lib.rs:6:63
  |
6 |     pub vulkan_device : ash::version::<Type as InstanceV1_0>::Device
  |                                                               ^^^^^^ not found in `ash::version`
  |
help: consider importing one of these items
  |
1 | use ash::Device;
  |
1 | use ash::vk::Device;
  |

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_metadata/src/rmeta/decoder.rs:900:54
note: run with `RUST_BACKTRACE=1` environment variable to display 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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.51.0 (2fd73fabe 2021-03-23) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [generics_of] computing generics of `ash::version`
#1 [opt_const_param_of] computing the optional const parameter of `GfxDevice::vulkan_device::{constant#0}`
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0412, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `bisect`

To learn more, run the command again with --verbose.

@hameerabbasi
Copy link
Contributor

hameerabbasi commented May 3, 2021

@rustbot modify labels -I-prioritize +P-medium

As discussed in the prioritization working group on Zulip

@rustbot rustbot added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 3, 2021
@hameerabbasi hameerabbasi added P-medium Medium priority and removed P-high High priority labels May 3, 2021
@steffahn
Copy link
Member

steffahn commented May 3, 2021

Minimized

fn f() {
    std::<_ as _>;   
}

@steffahn
Copy link
Member

steffahn commented May 3, 2021

Interesting thing… my minimized example only regresses at nightly-2020-11-16 (98d6634 to 603ab5b), however I can confirm the regression at nightly-2020-10-28 (fd54259 to 07e968b) for the original example.

fetching (via remote github) commits from max(fd542592f08ca0d1f7255600115c2eafdf6b5da7, 2020-10-25) to 07e968b640e8ff76fa8be4b48b70ab80ea577800
ending github query because we found starting sha: fd542592f08ca0d1f7255600115c2eafdf6b5da7
get_commits_between returning commits, len: 9
  commit[0] 2020-10-26UTC: Auto merge of #77187 - TimDiekmann:box-alloc, r=Amanieu
  commit[1] 2020-10-26UTC: Auto merge of #77876 - tmiasko:simplify-locals, r=wesleywiser
  commit[2] 2020-10-27UTC: Auto merge of #78421 - JohnTitor:rollup-bq2d7fo, r=JohnTitor
  commit[3] 2020-10-27UTC: Auto merge of #78359 - ssomers:btree_cleanup_mem, r=Mark-Simulacrum
  commit[4] 2020-10-27UTC: Auto merge of #77317 - varkor:break-diverging-value, r=nikomatsakis
  commit[5] 2020-10-27UTC: Auto merge of #77502 - varkor:const-generics-suggest-enclosing-braces, r=petrochenkov
  commit[6] 2020-10-27UTC: Auto merge of #78227 - SergioBenitez:test-stdout-threading, r=m-ou-se
  commit[7] 2020-10-27UTC: Auto merge of #78434 - jonas-schievink:disable-miropt, r=wesleywiser
  commit[8] 2020-10-27UTC: Auto merge of #76269 - ayrtonm:function-reference-lint, r=oli-obk
ERROR: no commits between fd542592f08ca0d1f7255600115c2eafdf6b5da7 and 07e968b640e8ff76fa8be4b48b70ab80ea577800 within last 167 days

AFAICT possibly #77502.

@steffahn
Copy link
Member

steffahn commented May 3, 2021

Ah, that makes sense… the later regression is due to #79016. Using std::<x as y> takes it back to nightly-2020-10-28.

@steffahn
Copy link
Member

steffahn commented May 3, 2021

Confirmed #77502 as the regression point.
cc @varkor @estebank

Edit: Probably not the underlying problem, see comments below.

@steffahn
Copy link
Member

steffahn commented May 3, 2021

@rustbot label -A-meta +A-frontend

@rustbot rustbot added A-frontend Area: Compiler frontend (errors, parsing and HIR) and removed A-meta Area: Issues & PRs about the rust-lang/rust repository itself labels May 3, 2021
@steffahn
Copy link
Member

steffahn commented May 3, 2021

Nevermind, further minimization to

fn f() {
    std::<0>;   
}

puts the regression point earlier than #77502.

********************************************************************************
Regression in nightly-2020-03-25
********************************************************************************

fetching https://static.rust-lang.org/dist/2020-03-24/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2020-03-24: 40 B / 40 B [================================================================================] 100.00 % 363.73 KB/s converted 2020-03-24 to 1edd389cc4c7b5be7a3dd4fe4b986f6017018e54
fetching https://static.rust-lang.org/dist/2020-03-25/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2020-03-25: 40 B / 40 B [================================================================================] 100.00 % 410.38 KB/s converted 2020-03-25 to 02046a5d402c789c006d0da7662f800fe3c45faf
looking for regression commit between 2020-03-24 and 2020-03-25
fetching (via remote github) commits from max(1edd389cc4c7b5be7a3dd4fe4b986f6017018e54, 2020-03-22) to 02046a5d402c789c006d0da7662f800fe3c45faf
ending github query because we found starting sha: 1edd389cc4c7b5be7a3dd4fe4b986f6017018e54
get_commits_between returning commits, len: 8
  commit[0] 2020-03-23UTC: Auto merge of #70330 - Centril:rollup-ts0clvx, r=Centril
  commit[1] 2020-03-23UTC: Auto merge of #70322 - matthiaskrgr:submodule_upd, r=Dylan-DPC
  commit[2] 2020-03-24UTC: Auto merge of #70343 - Centril:rollup-94egfvs, r=Centril
  commit[3] 2020-03-24UTC: Auto merge of #70351 - Centril:rollup-tveoq3w, r=Centril
  commit[4] 2020-03-24UTC: Auto merge of #69894 - vtbassmatt:master, r=nellshamrell
  commit[5] 2020-03-24UTC: Auto merge of #70163 - nikic:llvm-10-preparation, r=cuviper
  commit[6] 2020-03-24UTC: Auto merge of #70190 - pietroalbini:gha, r=Mark-Simulacrum
  commit[7] 2020-03-24UTC: Auto merge of #70371 - Centril:rollup-ywi1vo3, r=Centril
ERROR: no commits between 1edd389cc4c7b5be7a3dd4fe4b986f6017018e54 and 02046a5d402c789c006d0da7662f800fe3c45faf within last 167 days

@steffahn
Copy link
Member

steffahn commented May 3, 2021

The (error -> error+ICE) regression of the std::<0> example happens at #70284.

cc @lcnr

Compiler output/backtrace

on 1902d1e

error[E0423]: expected value, found crate `std`
 --> src/main.rs:2:5
  |
2 |     std::<0>; 
  |     ^^^^^^^^ not a value

error: aborting due to previous error

on 0a17c4c (with backtrace)

error[E0423]: expected value, found crate `std`
 --> src/main.rs:2:5
  |
2 |     std::<0>; 
  |     ^^^^^^^^ not a value

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/librustc_metadata/rmeta/decoder.rs:854:9
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::sys_common::backtrace::print
   4: std::panicking::default_hook::{{closure}}
   5: std::panicking::default_hook
   6: rustc_driver::report_ice
   7: std::panicking::rust_panic_with_hook
   8: rust_begin_unwind
   9: core::panicking::panic_fmt
  10: core::panicking::panic
  11: rustc_metadata::rmeta::decoder::<impl rustc_metadata::creader::CrateMetadataRef>::get_generics
  12: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::generics_of
  13: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::generics_of>::compute
  14: rustc::dep_graph::graph::DepGraph::with_task_impl
  15: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  16: rustc_typeck::collect::type_of::type_of
  17: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::type_of>::compute
  18: rustc::dep_graph::graph::DepGraph::with_task_impl
  19: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  20: rustc::ty::context::GlobalCtxt::enter_local
  21: rustc_infer::infer::InferCtxtBuilder::enter
  22: rustc_typeck::check::typeck_tables_of_with_fallback
  23: rustc_typeck::check::typeck_tables_of
  24: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  25: rustc::dep_graph::graph::DepGraph::with_task_impl
  26: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  27: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  28: rustc_typeck::check::typeck_item_bodies
  29: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_item_bodies>::compute
  30: rustc::dep_graph::graph::DepGraph::with_task_impl
  31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  32: rustc_session::utils::<impl rustc_session::session::Session>::time
  33: rustc_typeck::check_crate
  34: rustc_interface::passes::analysis
  35: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute
  36: rustc::dep_graph::graph::DepGraph::with_eval_always_task
  37: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  38: rustc::ty::context::tls::enter_global
  39: rustc_interface::interface::run_compiler_in_existing_thread_pool
  40: scoped_tls::ScopedKey<T>::set
  41: rustc_ast::attr::with_globals
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.44.0 (0a17c4c19 2020-03-23) 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

query stack during panic:
#0 [generics_of] processing `std`
#1 [type_of] processing `f::{{constant}}#0`
#2 [typeck_tables_of] type-checking `f::{{constant}}#0`
#3 [typeck_item_bodies] type-checking all item bodies
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

@hellow554
Copy link
Contributor

hellow554 commented May 3, 2021

As a reminder: Please add both code snippets as testcases in the final PR. They seem to be triggered differently, therefore it shouldn't hurt to add them both.

@estebank estebank self-assigned this May 4, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue May 4, 2021
Do not ICE on invalid const param

When encountering a path that can't have generics, do not call
`generics_of`. This would happen when writing something like
`path::this_is_a_mod<const_val>`.

Fix rust-lang#84831.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue May 4, 2021
Do not ICE on invalid const param

When encountering a path that can't have generics, do not call
`generics_of`. This would happen when writing something like
`path::this_is_a_mod<const_val>`.

Fix rust-lang#84831.
RalfJung added a commit to RalfJung/rust that referenced this issue May 5, 2021
Do not ICE on invalid const param

When encountering a path that can't have generics, do not call
`generics_of`. This would happen when writing something like
`path::this_is_a_mod<const_val>`.

Fix rust-lang#84831.
RalfJung added a commit to RalfJung/rust that referenced this issue May 5, 2021
Do not ICE on invalid const param

When encountering a path that can't have generics, do not call
`generics_of`. This would happen when writing something like
`path::this_is_a_mod<const_val>`.

Fix rust-lang#84831.
RalfJung added a commit to RalfJung/rust that referenced this issue May 5, 2021
Do not ICE on invalid const param

When encountering a path that can't have generics, do not call
`generics_of`. This would happen when writing something like
`path::this_is_a_mod<const_val>`.

Fix rust-lang#84831.
@bors bors closed this as completed in 11379f0 May 5, 2021
Mark-Simulacrum pushed a commit to Mark-Simulacrum/rust that referenced this issue May 22, 2021
When encountering a path that can't have generics, do not call
`generics_of`. This would happen when writing something like
`path::this_is_a_mod<const_val>`.

Fix rust-lang#84831.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) C-bug Category: This is a bug. 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.

6 participants