Skip to content

ICE: sty: None #138361

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

Open
matthiaskrgr opened this issue Mar 11, 2025 · 12 comments
Open

ICE: sty: None #138361

matthiaskrgr opened this issue Mar 11, 2025 · 12 comments
Labels
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.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Mar 11, 2025

snippet:

const fn x() {
    let array = [(); { loop {} }];
    let nan1: f64 = unsafe { std::mem::transmute([4]) };
}

fn main() {}

Version information

rustc 1.87.0-nightly (ebf0cf75d 2025-03-11)
binary: rustc
commit-hash: ebf0cf75d368c035f4c7e7246d203bd469ee4a51
commit-date: 2025-03-11
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Possibly related line of code:

}
}
}
impl<'tcx> rustc_type_ir::inherent::Tys<TyCtxt<'tcx>> for &'tcx ty::List<Ty<'tcx>> {
fn inputs(self) -> &'tcx [Ty<'tcx>] {
self.split_last().unwrap().1
}
fn output(self) -> Ty<'tcx> {
*self.split_last().unwrap().0
}
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: constant evaluation is taking a long time
 --> /tmp/icemaker_global_tempdir.OFXddYdTsfsI/rustc_testrunner_tmpdir_reporting.6eWFtohymixh/mvce.rs:2:24
  |
2 |     let array = [(); { loop {} }];
  |                        ^^^^^^^
  |
  = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
          If your compilation actually takes a long time, you can safely allow the lint.
help: the constant being evaluated
 --> /tmp/icemaker_global_tempdir.OFXddYdTsfsI/rustc_testrunner_tmpdir_reporting.6eWFtohymixh/mvce.rs:2:22
  |
2 |     let array = [(); { loop {} }];
  |                      ^^^^^^^^^^^
  = note: `#[deny(long_running_const_eval)]` on by default

warning: function `x` is never used
 --> /tmp/icemaker_global_tempdir.OFXddYdTsfsI/rustc_testrunner_tmpdir_reporting.6eWFtohymixh/mvce.rs:1:10
  |
1 | const fn x() {
  |          ^
  |
  = note: `#[warn(dead_code)]` on by default


thread 'rustc' panicked at compiler/rustc_middle/src/ty/sty.rs:2078:27:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7e3346625b33 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h7fb80f6afbe41a33
   1:     0x7e3346e059d8 - core::fmt::write::h000527be0eea6fe8
   2:     0x7e334824ffd1 - std::io::Write::write_fmt::h4991a22851475fb5
   3:     0x7e3346625992 - std::sys::backtrace::BacktraceLock::print::hffad87dde00cbe3e
   4:     0x7e33466282b8 - std::panicking::default_hook::{{closure}}::ha46397973bec1239
   5:     0x7e3346627dd7 - std::panicking::default_hook::h706de72a1550eed4
   6:     0x7e3345693abf - std[ea0914bf68e3efbf]::panicking::update_hook::<alloc[3dfe61f71ba45cfe]::boxed::Box<rustc_driver_impl[23cd132fe59c5dfc]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7e3346628b23 - std::panicking::rust_panic_with_hook::h6666776865bd21f5
   8:     0x7e33466287e6 - std::panicking::begin_panic_handler::{{closure}}::hb8595612365d24db
   9:     0x7e3346625ff9 - std::sys::backtrace::__rust_end_short_backtrace::h7037f177c7ae4ed3
  10:     0x7e33466284dd - rust_begin_unwind
  11:     0x7e3343070ea0 - core::panicking::panic_fmt::hd26142fa9828e2a3
  12:     0x7e3343ca041c - core::panicking::panic::h59ce24d70b84159e
  13:     0x7e3344576a39 - core::option::unwrap_failed::h48c0f1454ecd4af7
  14:     0x7e33473e27a6 - <rustc_lint[3f5ee35a34c41153]::BuiltinCombinedModuleLateLintPass as rustc_lint[3f5ee35a34c41153]::passes::LateLintPass>::check_expr
  15:     0x7e33476f2ee4 - <rustc_lint[3f5ee35a34c41153]::late::LateContextAndPass<rustc_lint[3f5ee35a34c41153]::BuiltinCombinedModuleLateLintPass> as rustc_hir[9c8f1de648b82ae]::intravisit::Visitor>::visit_expr
  16:     0x7e33476f31ab - <rustc_lint[3f5ee35a34c41153]::late::LateContextAndPass<rustc_lint[3f5ee35a34c41153]::BuiltinCombinedModuleLateLintPass> as rustc_hir[9c8f1de648b82ae]::intravisit::Visitor>::visit_expr
  17:     0x7e33476f1e6e - <rustc_lint[3f5ee35a34c41153]::late::LateContextAndPass<rustc_lint[3f5ee35a34c41153]::BuiltinCombinedModuleLateLintPass> as rustc_hir[9c8f1de648b82ae]::intravisit::Visitor>::visit_block
  18:     0x7e33476f3245 - <rustc_lint[3f5ee35a34c41153]::late::LateContextAndPass<rustc_lint[3f5ee35a34c41153]::BuiltinCombinedModuleLateLintPass> as rustc_hir[9c8f1de648b82ae]::intravisit::Visitor>::visit_expr
  19:     0x7e33476f203f - <rustc_lint[3f5ee35a34c41153]::late::LateContextAndPass<rustc_lint[3f5ee35a34c41153]::BuiltinCombinedModuleLateLintPass> as rustc_hir[9c8f1de648b82ae]::intravisit::Visitor>::visit_block
  20:     0x7e334727ccf5 - <rustc_lint[3f5ee35a34c41153]::late::LateContextAndPass<rustc_lint[3f5ee35a34c41153]::BuiltinCombinedModuleLateLintPass> as rustc_hir[9c8f1de648b82ae]::intravisit::Visitor>::visit_nested_body
  21:     0x7e334727718d - <rustc_lint[3f5ee35a34c41153]::late::LateContextAndPass<rustc_lint[3f5ee35a34c41153]::BuiltinCombinedModuleLateLintPass> as rustc_hir[9c8f1de648b82ae]::intravisit::Visitor>::visit_nested_item
  22:     0x7e3347275d3a - rustc_lint[3f5ee35a34c41153]::lint_mod
  23:     0x7e3347275a3d - rustc_query_impl[977456df771add7]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[977456df771add7]::query_impl::lint_mod::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8b56cfa39295cc9e]::query::erase::Erased<[u8; 0usize]>>
  24:     0x7e3347df874f - rustc_query_system[f942f53a11d60297]::query::plumbing::try_execute_query::<rustc_query_impl[977456df771add7]::DynamicConfig<rustc_query_system[f942f53a11d60297]::query::caches::DefaultCache<rustc_span[ef11c3aadf555ab3]::def_id::LocalModDefId, rustc_middle[8b56cfa39295cc9e]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[977456df771add7]::plumbing::QueryCtxt, false>
  25:     0x7e3347df783e - rustc_query_impl[977456df771add7]::query_impl::lint_mod::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7e3347df73fd - rustc_lint[3f5ee35a34c41153]::late::check_crate::{closure#1}
  27:     0x7e3347df6f78 - rustc_lint[3f5ee35a34c41153]::late::check_crate
  28:     0x7e3347dfa8f2 - rustc_interface[15b2602f89c3a5c0]::passes::analysis
  29:     0x7e3347dfa6d7 - rustc_query_impl[977456df771add7]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[977456df771add7]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8b56cfa39295cc9e]::query::erase::Erased<[u8; 0usize]>>
  30:     0x7e3347f1c981 - rustc_query_system[f942f53a11d60297]::query::plumbing::try_execute_query::<rustc_query_impl[977456df771add7]::DynamicConfig<rustc_query_system[f942f53a11d60297]::query::caches::SingleCache<rustc_middle[8b56cfa39295cc9e]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[977456df771add7]::plumbing::QueryCtxt, false>
  31:     0x7e3347f1c674 - rustc_query_impl[977456df771add7]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7e334815bfbc - rustc_interface[15b2602f89c3a5c0]::passes::create_and_enter_global_ctxt::<core[72d9f83855d8cc5b]::option::Option<rustc_interface[15b2602f89c3a5c0]::queries::Linker>, rustc_driver_impl[23cd132fe59c5dfc]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  33:     0x7e3347f74c97 - rustc_interface[15b2602f89c3a5c0]::interface::run_compiler::<(), rustc_driver_impl[23cd132fe59c5dfc]::run_compiler::{closure#0}>::{closure#1}
  34:     0x7e3347dd97c8 - std[ea0914bf68e3efbf]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[15b2602f89c3a5c0]::util::run_in_thread_with_globals<rustc_interface[15b2602f89c3a5c0]::util::run_in_thread_pool_with_globals<rustc_interface[15b2602f89c3a5c0]::interface::run_compiler<(), rustc_driver_impl[23cd132fe59c5dfc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  35:     0x7e3347dda0b4 - <<std[ea0914bf68e3efbf]::thread::Builder>::spawn_unchecked_<rustc_interface[15b2602f89c3a5c0]::util::run_in_thread_with_globals<rustc_interface[15b2602f89c3a5c0]::util::run_in_thread_pool_with_globals<rustc_interface[15b2602f89c3a5c0]::interface::run_compiler<(), rustc_driver_impl[23cd132fe59c5dfc]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[72d9f83855d8cc5b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x7e3347ddb4b7 - std::sys::pal::unix::thread::Thread::new::thread_start::ha1530b93ff336c49
  37:     0x7e3341ca370a - <unknown>
  38:     0x7e3341d27aac - <unknown>
  39:                0x0 - <unknown>

error: 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: please make sure that you have updated to the latest nightly

note: rustc 1.87.0-nightly (ebf0cf75d 2025-03-11) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [lint_mod] linting top-level module
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error; 1 warning emitted


@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 Mar 11, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 11, 2025
@matthiaskrgr
Copy link
Member Author

mvce probably

fn a() {
  [0; loop{}];
  std::mem::transmute(4)
}
fn main() {}

@matthiaskrgr
Copy link
Member Author

bisects to nightly-2024-02-23

@meithecatte
Copy link
Contributor

bisecting between nightly-2024-02-22 and nightly-2024-02-23

@meithecatte
Copy link
Contributor

bisection reports: 46f4983 is the first bad commit

cc @nnethercote

git bisect start
# status: waiting for both good and bad commits
# good: [3406ada96f8e16e49e947a91db3eba0db45245fa] Auto merge of #117658 - RalfJung:ptr-dangling, r=m-ou-se
git bisect good 3406ada96f8e16e49e947a91db3eba0db45245fa
# status: waiting for bad commit, 1 good commit known
# bad: [397937d812852f9bbeb671005cb399dbcb357cde] Auto merge of #119989 - lcnr:sub_relations-bye-bye, r=compiler-errors
git bisect bad 397937d812852f9bbeb671005cb399dbcb357cde
# bad: [52dba5ffe73c25951fd6ae38bf20513002dd7874] Auto merge of #121225 - RalfJung:simd-extract-insert-const-idx, r=oli-obk,Amanieu
git bisect bad 52dba5ffe73c25951fd6ae38bf20513002dd7874
# bad: [64dbc3f38f3ec80ad6c9246a2342810abd4c6daa] Rollup merge of #121392 - bjorn3:unify_dylib_loading, r=petrochenkov
git bisect bad 64dbc3f38f3ec80ad6c9246a2342810abd4c6daa
# bad: [5c89029585db9e7963cc67360213830703091f4d] Rollup merge of #121206 - nnethercote:top-level-error-handling, r=oli-obk
git bisect bad 5c89029585db9e7963cc67360213830703091f4d
# bad: [72b172bdf631483d0f802c54c8dc8246f6b4e00e] Overhaul the handling of errors at the top-level.
git bisect bad 72b172bdf631483d0f802c54c8dc8246f6b4e00e
# good: [203b4332bb3da3af092344b3459416aeab4c90ef] Remove dead `expect_error_or_delayed_bug` method.
git bisect good 203b4332bb3da3af092344b3459416aeab4c90ef
# bad: [46f49833566381887ba74e3f756271a6e8723636] Adjust the `has_errors*` methods.
git bisect bad 46f49833566381887ba74e3f756271a6e8723636
# good: [9919c3dab3e4eabe466612de5f6c472e3e27ceb6] Remove `EarlyDiagCtxt::abort_if_errors`.
git bisect good 9919c3dab3e4eabe466612de5f6c472e3e27ceb6
# first bad commit: [46f49833566381887ba74e3f756271a6e8723636] Adjust the `has_errors*` methods.

@meithecatte
Copy link
Contributor

Interestingly the panic I'm getting is different:

thread 'rustc' panicked at compiler/rustc_middle/src/ty/sty.rs:1293:32:
range end index 18446744073709551615 out of range for slice of length 0

@meithecatte
Copy link
Contributor

It seems that in both cases, what happens is that an FnSig / Tys with zero length gets created and then accessed,

@meithecatte
Copy link
Contributor

I think what's going on here is that the "constant evaluation is taking a long time" lint is getting triggered, aborts the typechecking of the function, and then the transmute lint trips over that – and because the former is a lint, it isn't enough for the lint passes to decide "this thing is broken enough that we shouldn't try to lint it"?

Not sure where is the code that actually implements this, though, and no idea why @nnethercote's commit would change this behavior.

@meithecatte
Copy link
Contributor

Okay, before the offending commit, an actual typechecking error gets emitted in addition to the long_running_const_eval lint.

error: constant evaluation is taking a long time
 --> ice138361.rs:2:7
  |
2 |   [0; loop{}];
  |       ^^^^^^
  |
  = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
          If your compilation actually takes a long time, you can safely allow the lint.
help: the constant being evaluated
 --> ice138361.rs:2:7
  |
2 |   [0; loop{}];
  |       ^^^^^^
  = note: `#[deny(long_running_const_eval)]` on by default

error[E0282]: type annotations needed
 --> ice138361.rs:2:3
  |
2 |   [0; loop{}];
  |   ^^^^^^^^^^^ cannot infer type for array `[{integer}; {const error}]`

@meithecatte
Copy link
Contributor

@rustbot claim

@meithecatte
Copy link
Contributor

It seems that this has the same root cause as #125323, and will likely get fixed with #138679.

@meithecatte
Copy link
Contributor

@rustbot unclaim

@meithecatte
Copy link
Contributor

cough

@rustbot release-assignment

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

No branches or pull requests

4 participants