Skip to content
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

ICE: expected wide pointer extra data #130970

Open
matthiaskrgr opened this issue Sep 28, 2024 · 3 comments
Open

ICE: expected wide pointer extra data #130970

matthiaskrgr opened this issue Sep 28, 2024 · 3 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

fn main() {
    extern "C" {
        static symbol: [usize];
    }
    println!("{}", symbol[0]);
}

original:

//~ ERROR rustc_outlives

const _: bool = false && false;
const _: bool = true && false;
const _: bool = {
    let mut x = true && false;
    x
};
const _TOO_LOW: () = { u64::from_str_radix("12345ABCD" 1); };

fn main() {
    extern "C" {
        static symbol: [usize]; //~ ERROR: the size for values of type
    }
    println!("{}", symbol[0]);
    //~^ ERROR: extern static is unsafe
}

Version information

rustc 1.83.0-nightly (851f69868 2024-09-28)
binary: rustc
commit-hash: 851f698682aa2e4c226e1a2c1af30adbcb63aae2
commit-date: 2024-09-28
host: x86_64-unknown-linux-gnu
release: 1.83.0-nightly
LLVM version: 19.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zmir-opt-level=5 -Zvalidate-mir

Program output

error[E0277]: the size for values of type `[usize]` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.UzS9t28kBj7Z/rustc_testrunner_tmpdir_reporting.ClR4SdutAcRi/mvce.rs:3:24
  |
3 |         static symbol: [usize];
  |                        ^^^^^^^ doesn't have a size known at compile-time
  |
  = help: the trait `Sized` is not implemented for `[usize]`

error[E0133]: use of extern static is unsafe and requires unsafe function or block
 --> /tmp/icemaker_global_tempdir.UzS9t28kBj7Z/rustc_testrunner_tmpdir_reporting.ClR4SdutAcRi/mvce.rs:5:20
  |
5 |     println!("{}", symbol[0]);
  |                    ^^^^^^ use of extern static
  |
  = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior

error: internal compiler error: /rustc/851f698682aa2e4c226e1a2c1af30adbcb63aae2/compiler/rustc_const_eval/src/interpret/place.rs:36:17: expected wide pointer extra data (e.g. slice length or trait object vtable)

thread 'rustc' panicked at /rustc/851f698682aa2e4c226e1a2c1af30adbcb63aae2/compiler/rustc_const_eval/src/interpret/place.rs:36:17:
Box<dyn Any>
stack backtrace:
   0:     0x7407a38ceaba - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h7900a3ecde60f42e
   1:     0x7407a40037e6 - core::fmt::write::h550ce993e33b1b64
   2:     0x7407a51ae991 - std::io::Write::write_fmt::h934b266016a01ab9
   3:     0x7407a38ce912 - std::sys::backtrace::BacktraceLock::print::hfed7190cfb479085
   4:     0x7407a38d0e31 - std::panicking::default_hook::{{closure}}::hf3239a9153976196
   5:     0x7407a38d0c64 - std::panicking::default_hook::ha9ae936b7eae362b
   6:     0x7407a299a03f - std[7abf0287877b87c3]::panicking::update_hook::<alloc[dcdda265b4d77909]::boxed::Box<rustc_driver_impl[2b0d10d4d558aac7]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x7407a38d1548 - std::panicking::rust_panic_with_hook::h62359f8c356e73f3
   8:     0x7407a29d41e1 - std[7abf0287877b87c3]::panicking::begin_panic::<rustc_errors[47f0f04182922d6e]::ExplicitBug>::{closure#0}
   9:     0x7407a29c7286 - std[7abf0287877b87c3]::sys::backtrace::__rust_end_short_backtrace::<std[7abf0287877b87c3]::panicking::begin_panic<rustc_errors[47f0f04182922d6e]::ExplicitBug>::{closure#0}, !>
  10:     0x7407a29c2769 - std[7abf0287877b87c3]::panicking::begin_panic::<rustc_errors[47f0f04182922d6e]::ExplicitBug>
  11:     0x7407a29dda71 - <rustc_errors[47f0f04182922d6e]::diagnostic::BugAbort as rustc_errors[47f0f04182922d6e]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7407a30020a4 - rustc_middle[8066596e1db03fa9]::util::bug::opt_span_bug_fmt::<rustc_span[19f86c6d4b17e07c]::span_encoding::Span>::{closure#0}
  13:     0x7407a2fe7dea - rustc_middle[8066596e1db03fa9]::ty::context::tls::with_opt::<rustc_middle[8066596e1db03fa9]::util::bug::opt_span_bug_fmt<rustc_span[19f86c6d4b17e07c]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7407a2fe7c7b - rustc_middle[8066596e1db03fa9]::ty::context::tls::with_context_opt::<rustc_middle[8066596e1db03fa9]::ty::context::tls::with_opt<rustc_middle[8066596e1db03fa9]::util::bug::opt_span_bug_fmt<rustc_span[19f86c6d4b17e07c]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7407a05cd630 - rustc_middle[8066596e1db03fa9]::util::bug::bug_fmt
  16:     0x7407a312dcf3 - <rustc_const_eval[45b572bde6308908]::interpret::place::MPlaceTy as rustc_const_eval[45b572bde6308908]::interpret::projection::Projectable<rustc_middle[8066596e1db03fa9]::mir::interpret::pointer::CtfeProvenance>>::len::<rustc_const_eval[45b572bde6308908]::const_eval::dummy_machine::DummyMachine>
  17:     0x7407a4a53010 - <rustc_mir_transform[7719501850dfb079]::gvn::VnState>::insert
  18:     0x7407a4a4519c - <rustc_mir_transform[7719501850dfb079]::gvn::VnState>::simplify_rvalue
  19:     0x7407a16394e4 - <rustc_mir_transform[7719501850dfb079]::gvn::GVN as rustc_mir_transform[7719501850dfb079]::pass_manager::MirPass>::run_pass
  20:     0x7407a400bd8d - rustc_mir_transform[7719501850dfb079]::pass_manager::run_passes_inner
  21:     0x7407a4a075e2 - rustc_mir_transform[7719501850dfb079]::optimized_mir
  22:     0x7407a4a05e9d - rustc_query_impl[6f1e8f04bf490f6a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6f1e8f04bf490f6a]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8066596e1db03fa9]::query::erase::Erased<[u8; 8usize]>>
  23:     0x7407a402fa38 - rustc_query_system[808f2ed519714d18]::query::plumbing::try_execute_query::<rustc_query_impl[6f1e8f04bf490f6a]::DynamicConfig<rustc_query_system[808f2ed519714d18]::query::caches::DefIdCache<rustc_middle[8066596e1db03fa9]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[6f1e8f04bf490f6a]::plumbing::QueryCtxt, false>
  24:     0x7407a402eff3 - rustc_query_impl[6f1e8f04bf490f6a]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  25:     0x7407a1480699 - <rustc_middle[8066596e1db03fa9]::ty::context::TyCtxt>::instance_mir
  26:     0x7407a43a47dc - rustc_interface[a8f766607a628292]::passes::run_required_analyses
  27:     0x7407a4b068de - rustc_interface[a8f766607a628292]::passes::analysis
  28:     0x7407a4b068b1 - rustc_query_impl[6f1e8f04bf490f6a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6f1e8f04bf490f6a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8066596e1db03fa9]::query::erase::Erased<[u8; 1usize]>>
  29:     0x7407a4e7892e - rustc_query_system[808f2ed519714d18]::query::plumbing::try_execute_query::<rustc_query_impl[6f1e8f04bf490f6a]::DynamicConfig<rustc_query_system[808f2ed519714d18]::query::caches::SingleCache<rustc_middle[8066596e1db03fa9]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[6f1e8f04bf490f6a]::plumbing::QueryCtxt, false>
  30:     0x7407a4e7860f - rustc_query_impl[6f1e8f04bf490f6a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7407a4d1825e - rustc_interface[a8f766607a628292]::interface::run_compiler::<core[9c5d060eac7beb80]::result::Result<(), rustc_span[19f86c6d4b17e07c]::ErrorGuaranteed>, rustc_driver_impl[2b0d10d4d558aac7]::run_compiler::{closure#0}>::{closure#1}
  32:     0x7407a4de3290 - std[7abf0287877b87c3]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a8f766607a628292]::util::run_in_thread_with_globals<rustc_interface[a8f766607a628292]::util::run_in_thread_pool_with_globals<rustc_interface[a8f766607a628292]::interface::run_compiler<core[9c5d060eac7beb80]::result::Result<(), rustc_span[19f86c6d4b17e07c]::ErrorGuaranteed>, rustc_driver_impl[2b0d10d4d558aac7]::run_compiler::{closure#0}>::{closure#1}, core[9c5d060eac7beb80]::result::Result<(), rustc_span[19f86c6d4b17e07c]::ErrorGuaranteed>>::{closure#0}, core[9c5d060eac7beb80]::result::Result<(), rustc_span[19f86c6d4b17e07c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9c5d060eac7beb80]::result::Result<(), rustc_span[19f86c6d4b17e07c]::ErrorGuaranteed>>
  33:     0x7407a4de38fa - <<std[7abf0287877b87c3]::thread::Builder>::spawn_unchecked_<rustc_interface[a8f766607a628292]::util::run_in_thread_with_globals<rustc_interface[a8f766607a628292]::util::run_in_thread_pool_with_globals<rustc_interface[a8f766607a628292]::interface::run_compiler<core[9c5d060eac7beb80]::result::Result<(), rustc_span[19f86c6d4b17e07c]::ErrorGuaranteed>, rustc_driver_impl[2b0d10d4d558aac7]::run_compiler::{closure#0}>::{closure#1}, core[9c5d060eac7beb80]::result::Result<(), rustc_span[19f86c6d4b17e07c]::ErrorGuaranteed>>::{closure#0}, core[9c5d060eac7beb80]::result::Result<(), rustc_span[19f86c6d4b17e07c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9c5d060eac7beb80]::result::Result<(), rustc_span[19f86c6d4b17e07c]::ErrorGuaranteed>>::{closure#1} as core[9c5d060eac7beb80]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7407a4de3ceb - std::sys::pal::unix::thread::Thread::new::thread_start::ha5204e3fc18d4472
  35:     0x7407a656039d - <unknown>
  36:     0x7407a65e549c - <unknown>
  37:                0x0 - <unknown>

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.83.0-nightly (851f69868 2024-09-28) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=5 -Z validate-mir -Z dump-mir-dir=dir

query stack during panic:
#0 [optimized_mir] optimizing MIR for `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0133, E0277.
For more information about an error, try `rustc --explain E0133`.

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

This bisects to #128612

@jieyouxu
Copy link
Member

Hm, it feels that it should not have reached const-eval, possibly error-tainting related?

@matthiaskrgr
Copy link
Member Author

yeah, probably

mvce:

//@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir
fn main() {
    extern "C" {
        static x: [usize];
    }
    x[0];
}

@jieyouxu jieyouxu added the S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue label Sep 28, 2024
@matthiaskrgr matthiaskrgr added S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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. labels Sep 29, 2024
@matthiaskrgr matthiaskrgr added 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. labels Oct 9, 2024
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 9, 2024
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) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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