Skip to content

ICE when placing extremely large array into extern "C" static block #93760

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
gh2o opened this issue Feb 8, 2022 · 1 comment · Fixed by #93850
Closed

ICE when placing extremely large array into extern "C" static block #93760

gh2o opened this issue Feb 8, 2022 · 1 comment · Fixed by #93850
Assignees
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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

@gh2o
Copy link
Contributor

gh2o commented Feb 8, 2022

Might be related to #49230.

Code

Command: rustc --crate-type lib ice.rs

extern "C" {
    static FOO: [usize; usize::MAX];
}

Meta

rustc --version --verbose:

rustc 1.60.0-nightly (734368a20 2022-02-07)
binary: rustc
commit-hash: 734368a200904ef9c21db86c595dc04263c87be0
commit-date: 2022-02-07
host: x86_64-unknown-linux-gnu
release: 1.60.0-nightly
LLVM version: 13.0.0

Error output

warning: static is never used: `FOO`
 --> maxice.rs:2:5
  |
2 |     static FOO: [usize; usize::MAX];
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

error: internal compiler error: generic static must be rejected
 --> maxice.rs:2:5
  |
2 |     static FOO: [usize; usize::MAX];
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_typeck/src/check/check.rs:417:22

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.60.0-nightly (734368a20 2022-02-07) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

query stack during panic:
end of query stack
Backtrace

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1176:13
stack backtrace:
   0:     0x7f91ad32195c - std::backtrace_rs::backtrace::libunwind::trace::hc5a503817bd73289
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f91ad32195c - std::backtrace_rs::backtrace::trace_unsynchronized::ha5e9cc1d53774ba1
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f91ad32195c - std::sys_common::backtrace::_print_fmt::h7143a255c4b168d7
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f91ad32195c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h34d2d031d26c186c
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f91ad382e9c - core::fmt::write::he926609825430387
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/core/src/fmt/mod.rs:1190:17
   5:     0x7f91ad311c88 - std::io::Write::write_fmt::hce0f3bebaac812fb
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/std/src/io/mod.rs:1657:15
   6:     0x7f91ad3258d7 - std::sys_common::backtrace::_print::h5d69a1544bb179ad
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f91ad3258d7 - std::sys_common::backtrace::print::hd6ead548dffd928d
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f91ad3258d7 - std::panicking::default_hook::{{closure}}::hb775318fdc953e3c
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/std/src/panicking.rs:295:22
   9:     0x7f91ad32559f - std::panicking::default_hook::h9606697911ae4fb9
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/std/src/panicking.rs:314:9
  10:     0x7f91adb05c71 - rustc_driver[ced724fed359e297]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f91ad3261b5 - std::panicking::rust_panic_with_hook::hd1c411b756534575
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/std/src/panicking.rs:702:17
  12:     0x7f91ad325e67 - std::panicking::begin_panic_handler::{{closure}}::h6c941f6fd9763425
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/std/src/panicking.rs:588:13
  13:     0x7f91ad321e04 - std::sys_common::backtrace::__rust_end_short_backtrace::h8072e4bfb1cfe728
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f91ad325b69 - rust_begin_unwind
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/std/src/panicking.rs:584:5
  15:     0x7f91ad2edb53 - core::panicking::panic_fmt::hc41d4433c2a0561a
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/core/src/panicking.rs:143:14
  16:     0x7f91aebebc9c - core[6ee678d30211edc4]::panicking::panic_display::<&str>
  17:     0x7f91b027ad2d - <rustc_errors[db71682845c93fee]::HandlerInner>::flush_delayed
  18:     0x7f91b02791ed - <rustc_errors[db71682845c93fee]::HandlerInner as core[6ee678d30211edc4]::ops::drop::Drop>::drop
  19:     0x7f91af9a38f6 - core[6ee678d30211edc4]::ptr::drop_in_place::<rustc_session[8aaf4b177c46bfae]::parse::ParseSess>
  20:     0x7f91af9a5a9a - <alloc[ffb4d2e801bcd412]::rc::Rc<rustc_session[8aaf4b177c46bfae]::session::Session> as core[6ee678d30211edc4]::ops::drop::Drop>::drop
  21:     0x7f91af995f7c - core[6ee678d30211edc4]::ptr::drop_in_place::<rustc_interface[3b5c713d1bebe036]::interface::Compiler>
  22:     0x7f91af99678c - rustc_span[84c0d6079ac7a8cb]::with_source_map::<core[6ee678d30211edc4]::result::Result<(), rustc_errors[db71682845c93fee]::ErrorReported>, rustc_interface[3b5c713d1bebe036]::interface::create_compiler_and_run<core[6ee678d30211edc4]::result::Result<(), rustc_errors[db71682845c93fee]::ErrorReported>, rustc_driver[ced724fed359e297]::run_compiler::{closure#1}>::{closure#1}>
  23:     0x7f91af992ef3 - rustc_interface[3b5c713d1bebe036]::interface::create_compiler_and_run::<core[6ee678d30211edc4]::result::Result<(), rustc_errors[db71682845c93fee]::ErrorReported>, rustc_driver[ced724fed359e297]::run_compiler::{closure#1}>
  24:     0x7f91af979102 - std[82b180ce3caceca0]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3b5c713d1bebe036]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[3b5c713d1bebe036]::interface::run_compiler<core[6ee678d30211edc4]::result::Result<(), rustc_errors[db71682845c93fee]::ErrorReported>, rustc_driver[ced724fed359e297]::run_compiler::{closure#1}>::{closure#0}, core[6ee678d30211edc4]::result::Result<(), rustc_errors[db71682845c93fee]::ErrorReported>>::{closure#0}, core[6ee678d30211edc4]::result::Result<(), rustc_errors[db71682845c93fee]::ErrorReported>>
  25:     0x7f91af9767a9 - <<std[82b180ce3caceca0]::thread::Builder>::spawn_unchecked_<rustc_interface[3b5c713d1bebe036]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[3b5c713d1bebe036]::interface::run_compiler<core[6ee678d30211edc4]::result::Result<(), rustc_errors[db71682845c93fee]::ErrorReported>, rustc_driver[ced724fed359e297]::run_compiler::{closure#1}>::{closure#0}, core[6ee678d30211edc4]::result::Result<(), rustc_errors[db71682845c93fee]::ErrorReported>>::{closure#0}, core[6ee678d30211edc4]::result::Result<(), rustc_errors[db71682845c93fee]::ErrorReported>>::{closure#1} as core[6ee678d30211edc4]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  26:     0x7f91ad331bf3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h0d2690c85d56dab9
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/alloc/src/boxed.rs:1854:9
  27:     0x7f91ad331bf3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hdf9b3e67298f34e0
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/alloc/src/boxed.rs:1854:9
  28:     0x7f91ad331bf3 - std::sys::unix::thread::Thread::new::thread_start::h3b72795a7bcc09f4
                               at /rustc/734368a200904ef9c21db86c595dc04263c87be0/library/std/src/sys/unix/thread.rs:108:17
  29:     0x7f91ad22f259 - start_thread
  30:     0x7f91ad14d5e3 - __GI___clone
  31:                0x0 - <unknown>

@gh2o gh2o 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 Feb 8, 2022
@asquared31415
Copy link
Contributor

@rustbot claim

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Feb 10, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 25, 2022
…e, r=jackh726

Don't ICE when an extern static is too big for the current architecture

Fixes rust-lang#93760

Emit an error instead of ICEing when an `extern` static's size overflows the allowed maximum for the target.

Changes the error message in the existing `delay_span_bug` call to the true layout error, first for debugging purposes, but opted to leave in to potentially assist future developers as it was being reached in unexpected ways already.
@bors bors closed this as completed in 54fa9ca Feb 25, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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

Successfully merging a pull request may close this issue.

3 participants