Skip to content

Rustc crashes at compiler/rustc_middle/src/ty/generics.rs:223:29 caused by index out of bounds #136141

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

Closed
wangbo15 opened this issue Jan 27, 2025 · 2 comments
Labels
requires-internal-features This issue requires the use of internal features.

Comments

@wangbo15
Copy link

Code

This one is also highly similar to #136138 and #136139, which is caused by the first line #!feature(intrinsics)]. Still, based on their different stack traces and triggered assertions, I think this is a new one.

#![feature(intrinsics)]
fn main() {
    transmute();
}
extern "rust-intrinsic" fn transmute() {
}

Meta

rustc --version --verbose:

rustc 1.86.0-nightly (f85c6de55 2025-01-26)
binary: rustc
commit-hash: f85c6de55206dbee5ffedfd821df1503a7b92346
commit-date: 2025-01-26
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Error output

warning: the feature `intrinsics` is internal to the compiler or standard library
 --> 3.rs:1:12
  |
1 | #![feature(intrinsics)]
  |            ^^^^^^^^^^
  |
  = note: using it is strongly discouraged
  = note: `#[warn(internal_features)]` on by default


thread 'rustc' panicked at compiler/rustc_middle/src/ty/generics.rs:223:29:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7fb6a6460210 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hec9bc6463e252640
   1:     0x7fb6a6cd0ee6 - core::fmt::write::h962cad0079919c7e
   2:     0x7fb6a7bcec51 - std::io::Write::write_fmt::h081e59591f35f868
   3:     0x7fb6a6460072 - std::sys::backtrace::BacktraceLock::print::he0deffbd85e9a2c5
   4:     0x7fb6a64624f2 - std::panicking::default_hook::{{closure}}::h99776b3a5456e866
   5:     0x7fb6a646237a - std::panicking::default_hook::hcad38b9ed4b5517d
   6:     0x7fb6a5617279 - std[cc940dec3ff43b12]::panicking::update_hook::<alloc[5f7a888829935c2b]::boxed::Box<rustc_driver_impl[af2bdb3744899392]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7fb6a6463073 - std::panicking::rust_panic_with_hook::hbfeeff1ab3569ba1
   8:     0x7fb6a6462d6a - std::panicking::begin_panic_handler::{{closure}}::h32c93c4f5d28ab99
   9:     0x7fb6a64606e9 - std::sys::backtrace::__rust_end_short_backtrace::h1884c239824d44f7
  10:     0x7fb6a6462a2d - rust_begin_unwind
  11:     0x7fb6a30f5bd0 - core::panicking::panic_fmt::he58927c3c03479ba
  12:     0x7fb6a4d3db79 - core::panicking::panic_bounds_check::hc63b12e46b4e3bca
  13:     0x7fb6a89c7553 - <rustc_middle[ea35cf57050946b4]::ty::generics::Generics>::param_at.cold
  14:     0x7fb6a57bcae6 - rustc_hir_analysis[ce12ae6d63b57b8a]::check::intrinsic::check_intrinsic_type
  15:     0x7fb6a72f3686 - rustc_hir_analysis[ce12ae6d63b57b8a]::check::wfcheck::check_well_formed
  16:     0x7fb6a72f2247 - rustc_query_impl[52b9445d4dcf70be]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[52b9445d4dcf70be]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ea35cf57050946b4]::query::erase::Erased<[u8; 1usize]>>
  17:     0x7fb6a72f1ce9 - rustc_query_system[b5c6449b7ccd2566]::query::plumbing::try_execute_query::<rustc_query_impl[52b9445d4dcf70be]::DynamicConfig<rustc_data_structures[aef26e4d10f0fc6d]::vec_cache::VecCache<rustc_span[d5a27b28009c9e0]::def_id::LocalDefId, rustc_middle[ea35cf57050946b4]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[b5c6449b7ccd2566]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[52b9445d4dcf70be]::plumbing::QueryCtxt, false>
  18:     0x7fb6a72f1746 - rustc_query_impl[52b9445d4dcf70be]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  19:     0x7fb6a72ef36c - rustc_hir_analysis[ce12ae6d63b57b8a]::check::wfcheck::check_mod_type_wf
  20:     0x7fb6a72ef18b - rustc_query_impl[52b9445d4dcf70be]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[52b9445d4dcf70be]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ea35cf57050946b4]::query::erase::Erased<[u8; 1usize]>>
  21:     0x7fb6a7bd6ac8 - rustc_query_system[b5c6449b7ccd2566]::query::plumbing::try_execute_query::<rustc_query_impl[52b9445d4dcf70be]::DynamicConfig<rustc_query_system[b5c6449b7ccd2566]::query::caches::DefaultCache<rustc_span[d5a27b28009c9e0]::def_id::LocalModDefId, rustc_middle[ea35cf57050946b4]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[52b9445d4dcf70be]::plumbing::QueryCtxt, false>
  22:     0x7fb6a7bd6870 - rustc_query_impl[52b9445d4dcf70be]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  23:     0x7fb6a705b1e6 - rustc_hir_analysis[ce12ae6d63b57b8a]::check_crate
  24:     0x7fb6a7057aa2 - rustc_interface[d0d5d02e7a56d74f]::passes::run_required_analyses
  25:     0x7fb6a7bca35e - rustc_interface[d0d5d02e7a56d74f]::passes::analysis
  26:     0x7fb6a7bca32f - rustc_query_impl[52b9445d4dcf70be]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[52b9445d4dcf70be]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ea35cf57050946b4]::query::erase::Erased<[u8; 0usize]>>
  27:     0x7fb6a7bb7315 - rustc_query_system[b5c6449b7ccd2566]::query::plumbing::try_execute_query::<rustc_query_impl[52b9445d4dcf70be]::DynamicConfig<rustc_query_system[b5c6449b7ccd2566]::query::caches::SingleCache<rustc_middle[ea35cf57050946b4]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[52b9445d4dcf70be]::plumbing::QueryCtxt, false>
  28:     0x7fb6a7bb704e - rustc_query_impl[52b9445d4dcf70be]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7fb6a7bdd429 - rustc_interface[d0d5d02e7a56d74f]::passes::create_and_enter_global_ctxt::<core[c1de5c9ad145c0db]::option::Option<rustc_interface[d0d5d02e7a56d74f]::queries::Linker>, rustc_driver_impl[af2bdb3744899392]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  30:     0x7fb6a7c28213 - rustc_interface[d0d5d02e7a56d74f]::interface::run_compiler::<(), rustc_driver_impl[af2bdb3744899392]::run_compiler::{closure#0}>::{closure#1}
  31:     0x7fb6a7b24eb5 - std[cc940dec3ff43b12]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d0d5d02e7a56d74f]::util::run_in_thread_with_globals<rustc_interface[d0d5d02e7a56d74f]::util::run_in_thread_pool_with_globals<rustc_interface[d0d5d02e7a56d74f]::interface::run_compiler<(), rustc_driver_impl[af2bdb3744899392]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  32:     0x7fb6a7b24b99 - <<std[cc940dec3ff43b12]::thread::Builder>::spawn_unchecked_<rustc_interface[d0d5d02e7a56d74f]::util::run_in_thread_with_globals<rustc_interface[d0d5d02e7a56d74f]::util::run_in_thread_pool_with_globals<rustc_interface[d0d5d02e7a56d74f]::interface::run_compiler<(), rustc_driver_impl[af2bdb3744899392]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[c1de5c9ad145c0db]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7fb6a7b2432b - std::sys::pal::unix::thread::Thread::new::thread_start::hb22e947f5885a296
  34:     0x7fb6a1e7a609 - start_thread
                               at /build/glibc-LcI20x/glibc-2.31/nptl/pthread_create.c:477:8
  35:     0x7fb6a1d9f353 - clone
                               at /build/glibc-LcI20x/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95:0
  36:                0x0 - <unknown>

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

note: using internal features is not supported and expected to cause internal compiler errors when used incorrectly

note: please attach the file at `/home/nightwish/workspace/compiler/rust_test/2025-01-23/rustc-ice-2025-01-27T15_19_25-25784.txt` to your bug report

query stack during panic:
#0 [check_well_formed] checking that `transmute` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
warning: 1 warning emitted
Backtrace

<backtrace>

@wangbo15 wangbo15 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 Jan 27, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 27, 2025
@cyrgani
Copy link
Contributor

cyrgani commented Jan 27, 2025

Intrinsics are an internal feature and AFAIK ICEs when misusing it are expected and won't be fixed (note: using internal features is not supported and expected to cause internal compiler errors when used incorrectly is also at the bottom of the backtrace.)

@compiler-errors
Copy link
Member

@cyrgani is correct.

@compiler-errors compiler-errors closed this as not planned Won't fix, can't repro, duplicate, stale Jan 27, 2025
@fmease fmease added requires-internal-features This issue requires the use of internal features. and removed 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. C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
requires-internal-features This issue requires the use of internal features.
Projects
None yet
Development

No branches or pull requests

5 participants