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: InterErrorInfo / Unsupported with -Zmiri-symbolic-alignment-check #3288

Closed
matthiaskrgr opened this issue Feb 3, 2024 · 0 comments · Fixed by rust-lang/rust#120683
Closed

Comments

@matthiaskrgr
Copy link
Member

// check-pass

// This is a regression test for ICEs from
// https://github.com/rust-lang/rust/issues/71612
// and
// https://github.com/rust-lang/rust/issues/71709

#[derive(Copy, Clone)]
pub struct Glfw;

static mut GLFW: Option<Glfw> = None;
pub fn new() -> Glfw {
    unsafe {
        if let Some(glfw) = GLFW {
            return glfw;
        } else {
            todo!()
        }
    };
}

extern "C" {
    static _dispatch_queue_attr_concurrent: [u8; 0];
}

static DISPATCH_QUEUE_CONCURRENT: &'static [u8; 0] =
    unsafe { &_dispatch_queue_attr_concurrent };

fn main() {
    *DISPATCH_QUEUE_CONCURRENT;
    new();
}

MIRIFLAGS="-Zmiri-symbolic-alignment-check " cargo miri run

Preparing a sysroot for Miri (target: x86_64-unknown-linux-gnu)... done
WARNING: Ignoring `RUSTC_WRAPPER` environment variable, Miri does not support wrapping.
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `/home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo-miri runner target/miri/x86_64-unknown-linux-gnu/debug/ice`
warning: unused unary operation that must be used
  --> src/main.rs:30:5
   |
30 |     *DISPATCH_QUEUE_CONCURRENT;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ the unary operation produces a value
   |
   = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
   |
30 |     let _ = *DISPATCH_QUEUE_CONCURRENT;
   |     +++++++

thread 'rustc' panicked at src/tools/miri/src/machine.rs:896:56:
called `Result::unwrap()` on an `Err` value: InterpErrorInfo(InterpErrorInfoInner { kind: Unsupported(Unsupported("`extern` static `_dispatch_queue_attr_concurrent` from crate `ice` is not supported by Miri")), backtrace: InterpErrorBacktrace { backtrace: None } })
stack backtrace:
   0:     0x7fd269222d16 - std::backtrace_rs::backtrace::libunwind::trace::he544685250360e22
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fd269222d16 - std::backtrace_rs::backtrace::trace_unsynchronized::h664adef12633380a
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fd269222d16 - std::sys_common::backtrace::_print_fmt::hba7ee045aeee07b0
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fd269222d16 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc80b7ff177a688f2
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fd269275770 - core::fmt::rt::Argument::fmt::h605309ab4829b6b5
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/core/src/fmt/rt.rs:142:9
   5:     0x7fd269275770 - core::fmt::write::h5f24f526de99e105
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fd26921661f - std::io::Write::write_fmt::h711c920f97cd3d8c
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/io/mod.rs:1846:15
   7:     0x7fd269222af4 - std::sys_common::backtrace::_print::ha279702af2871260
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fd269222af4 - std::sys_common::backtrace::print::hc1f3820f405abdd3
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fd269225887 - std::panicking::default_hook::{{closure}}::h5058841d19c78172
  10:     0x7fd2692255e9 - std::panicking::default_hook::h60a42497ec033f97
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/panicking.rs:292:9
  11:     0x7fd265f371fc - std[4337b1e3d1c66af6]::panicking::update_hook::<alloc[6a28242b4f343ab9]::boxed::Box<rustc_driver_impl[e51f6499da6a94b9]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fd269225fd6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h437fd8fcb0ff0cea
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/alloc/src/boxed.rs:2029:9
  13:     0x7fd269225fd6 - std::panicking::rust_panic_with_hook::h294fbe090fe44fa4
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/panicking.rs:785:13
  14:     0x7fd269225d22 - std::panicking::begin_panic_handler::{{closure}}::h2074d67fa119e5b4
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/panicking.rs:659:13
  15:     0x7fd269223216 - std::sys_common::backtrace::__rust_end_short_backtrace::h1e9fefdcf90d724c
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7fd269225a74 - rust_begin_unwind
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/panicking.rs:647:5
  17:     0x7fd269271e75 - core::panicking::panic_fmt::h4707f51af56598f7
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/core/src/panicking.rs:72:14
  18:     0x7fd269272573 - core::result::unwrap_failed::h252c292c1db352c0
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/core/src/result.rs:1649:5
  19:     0x557358fcaa9e - <rustc_const_eval[47fec39e217f91ee]::interpret::eval_context::InterpCx<miri[5697a765cfc7294]::machine::MiriMachine>>::is_ptr_misaligned
  20:     0x557358fdd014 - <rustc_const_eval[47fec39e217f91ee]::interpret::eval_context::InterpCx<miri[5697a765cfc7294]::machine::MiriMachine>>::ref_to_mplace
  21:     0x557358fc3c9e - <rustc_const_eval[47fec39e217f91ee]::interpret::validity::ValidityVisitor<miri[5697a765cfc7294]::machine::MiriMachine>>::check_safe_pointer
  22:     0x557358ff2a2d - <rustc_const_eval[47fec39e217f91ee]::interpret::validity::ValidityVisitor<miri[5697a765cfc7294]::machine::MiriMachine> as rustc_const_eval[47fec39e217f91ee]::interpret::visitor::ValueVisitor<miri[5697a765cfc7294]::machine::MiriMachine>>::visit_value
  23:     0x557358fcae2c - <rustc_const_eval[47fec39e217f91ee]::interpret::eval_context::InterpCx<miri[5697a765cfc7294]::machine::MiriMachine>>::validate_operand_internal
  24:     0x557358fbe4a4 - <rustc_const_eval[47fec39e217f91ee]::interpret::eval_context::InterpCx<miri[5697a765cfc7294]::machine::MiriMachine>>::eval_rvalue_into_place
  25:     0x55735903d583 - <rustc_const_eval[47fec39e217f91ee]::interpret::eval_context::InterpCx<miri[5697a765cfc7294]::machine::MiriMachine> as miri[5697a765cfc7294]::concurrency::thread::EvalContextExt>::run_threads
  26:     0x55735904dab4 - miri[5697a765cfc7294]::eval::eval_entry
  27:     0x557358e8be63 - <miri[bfa1a3b834c7e317]::MiriCompilerCalls as rustc_driver_impl[e51f6499da6a94b9]::Callbacks>::after_analysis
  28:     0x7fd267f182ee - rustc_interface[e57535df52585ed5]::interface::run_compiler::<core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>, rustc_driver_impl[e51f6499da6a94b9]::run_compiler::{closure#0}>::{closure#0}
  29:     0x7fd267bada86 - std[4337b1e3d1c66af6]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e57535df52585ed5]::util::run_in_thread_with_globals<rustc_interface[e57535df52585ed5]::util::run_in_thread_pool_with_globals<rustc_interface[e57535df52585ed5]::interface::run_compiler<core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>, rustc_driver_impl[e51f6499da6a94b9]::run_compiler::{closure#0}>::{closure#0}, core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>>::{closure#0}, core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>>
  30:     0x7fd267bad8b3 - <<std[4337b1e3d1c66af6]::thread::Builder>::spawn_unchecked_<rustc_interface[e57535df52585ed5]::util::run_in_thread_with_globals<rustc_interface[e57535df52585ed5]::util::run_in_thread_pool_with_globals<rustc_interface[e57535df52585ed5]::interface::run_compiler<core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>, rustc_driver_impl[e51f6499da6a94b9]::run_compiler::{closure#0}>::{closure#0}, core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>>::{closure#0}, core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[cc6cd760d986f799]::result::Result<(), rustc_span[ecf473d7733698d2]::ErrorGuaranteed>>::{closure#1} as core[cc6cd760d986f799]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  31:     0x7fd26922f675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc4b9a6efba849e51
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/alloc/src/boxed.rs:2015:9
  32:     0x7fd26922f675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc525ee5ac423ddcd
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/alloc/src/boxed.rs:2015:9
  33:     0x7fd26922f675 - std::sys::pal::unix::thread::Thread::new::thread_start::h31b81f67226864c0
                               at /rustc/bf3c6c5bed498f41ad815641319a1ad9bcecb8e8/library/std/src/sys/pal/unix/thread.rs:108:17
  34:     0x7fd262fbd9eb - <unknown>
  35:     0x7fd2630417cc - <unknown>
  36:                0x0 - <unknown>

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

note: we would appreciate a bug report: https://github.com/rust-lang/miri/issues/new

note: please attach the file at `/tmp/im/ice/rustc-ice-2024-02-03T16_27_38-2424885.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -C target-cpu=native -Z miri-symbolic-alignment-check

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

query stack during panic:
end of query stack

Miri caused an ICE during evaluation. Here's the interpreter backtrace at the time of the panic:
note: the place in the program where the ICE was triggered
  --> src/main.rs:30:6
   |
30 |     *DISPATCH_QUEUE_CONCURRENT;
   |      ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: inside `main` at src/main.rs:30:6: 30:31
   = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5: 250:71
   = note: inside `std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:155:18: 155:21
   = note: inside closure at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:166:18: 166:82
   = note: inside `std::ops::function::impls::<impl std::ops::FnOnce<()> for &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>::call_once` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:284:13: 284:31
   = note: inside `std::panicking::r#try::do_call::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:554:40: 554:43
   = note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:518:19: 518:81
   = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:142:14: 142:33
   = note: inside closure at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:148:48: 148:73
   = note: inside `std::panicking::r#try::do_call::<{closure@std::rt::lang_start_internal::{closure#2}}, isize>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:554:40: 554:43
   = note: inside `std::panicking::r#try::<isize, {closure@std::rt::lang_start_internal::{closure#2}}>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:518:19: 518:81
   = note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#2}}, isize>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:142:14: 142:33
   = note: inside `std::rt::lang_start_internal` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:148:20: 148:98
   = note: inside `std::rt::lang_start::<()>` at /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:165:17: 170:6

warning: 1 warning emitted
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 6, 2024
Rollup merge of rust-lang#120683 - RalfJung:symbolic-alignment-ice, r=oli-obk

miri: fix ICE with symbolic alignment check on extern static

Fixes rust-lang/miri#3288. Also fixes [this example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=38ee338ff10726be72bdd6efa3386763).

This could almost be a Miri PR, except for that typo fix in the validator. I started this as a rustc patch since I thought I need rustc changes, and now it'd be too annoying to turn this into a Miri PR...

r? `@oli-obk`
github-actions bot pushed a commit that referenced this issue Feb 8, 2024
miri: fix ICE with symbolic alignment check on extern static

Fixes #3288. Also fixes [this example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=38ee338ff10726be72bdd6efa3386763).

This could almost be a Miri PR, except for that typo fix in the validator. I started this as a rustc patch since I thought I need rustc changes, and now it'd be too annoying to turn this into a Miri PR...

r? `@oli-obk`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant