Skip to content

tests/pass-dep/getrandom.rs ICEs on Solaris #3924

Closed
@RalfJung

Description

@RalfJung

To reproduce, run ./miri run --target x86_64-pc-solaris --dep tests/pass-dep/getrandom.rs:

thread 'rustc' panicked at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_middle/src/mir/interpret/allocation.rs:268:9:
access outside the bounds for given AllocRange
stack backtrace:
   0:     0x7f3c566c369a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::ha447345df90d3ac4
   1:     0x7f3c56e03b26 - core::fmt::write::h466a57c98a77c4c8
   2:     0x7f3c57fb3d91 - std::io::Write::write_fmt::h06aa3416825331fc
   3:     0x7f3c566c34f2 - std::sys::backtrace::BacktraceLock::print::h48912729c133c7cd
   4:     0x7f3c566c5a11 - std::panicking::default_hook::{{closure}}::he1ab6da666cf833c
   5:     0x7f3c566c5844 - std::panicking::default_hook::h29c45a7cda56f01e
   6:     0x7f3c55794d8f - std[dac38a4e0a05c6f4]::panicking::update_hook::<alloc[3cb49987d7d52dfa]::boxed::Box<rustc_driver_impl[7b961fc7fcd0c978]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x7f3c566c6128 - std::panicking::rust_panic_with_hook::h58068abffd3014be
   8:     0x7f3c566c5ec6 - std::panicking::begin_panic_handler::{{closure}}::hfe49947e5924540e
   9:     0x7f3c566c3b49 - std::sys::backtrace::__rust_end_short_backtrace::h12b9a6ca3ecd5f11
  10:     0x7f3c566c5bbc - rust_begin_unwind
  11:     0x7f3c53ff74a0 - core::panicking::panic_fmt::hf49c01a75532fe35
  12:     0x555edd631c8f - <rustc_middle[68ce78ea38d5ac48]::mir::interpret::allocation::AllocRange>::subrange
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_middle/src/mir/interpret/allocation.rs:268:9
  13:     0x555edd6321a3 - rustc_const_eval::interpret::memory::AllocRefMut<Prov,Extra,Bytes>::write_scalar::h18256c7792f6198d
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_const_eval/src/interpret/memory.rs:1145:21
  14:     0x555edd475ce0 - rustc_const_eval::interpret::place::<impl rustc_const_eval::interpret::eval_context::InterpCx<M>>::write_immediate_to_mplace_no_validate::hc3aa999de022d712
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_const_eval/src/interpret/place.rs:691:17
  15:     0x555edd475b36 - rustc_const_eval::interpret::place::<impl rustc_const_eval::interpret::eval_context::InterpCx<M>>::write_immediate_no_validate::hdeae26d7c0bae8bd
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_const_eval/src/interpret/place.rs:660:17
  16:     0x555edd4e1acf - rustc_const_eval::interpret::place::<impl rustc_const_eval::interpret::eval_context::InterpCx<M>>::write_immediate::hbf7558bddc3c797b
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_const_eval/src/interpret/place.rs:601:9
  17:     0x555edd4e1acf - rustc_const_eval::interpret::place::<impl rustc_const_eval::interpret::eval_context::InterpCx<M>>::write_scalar::h520c3610dc2dd9fc
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_const_eval/src/interpret/place.rs:623:9
  18:     0x555edd4e1acf - miri::shims::unix::foreign_items::EvalContextExt::emulate_foreign_item_inner::h1e0a7fd7082a8177
                               at /home/r/src/rust/miri/src/shims/unix/foreign_items.rs:793:17
  19:     0x555edd53c022 - miri::shims::foreign_items::EvalContextExtPriv::emulate_foreign_item_inner::hafdf85498df4b47d
                               at /home/r/src/rust/miri/src/shims/foreign_items.rs:991:25
  20:     0x555edd53824a - miri::shims::foreign_items::EvalContextExt::emulate_foreign_item::h52498fea84100e30
                               at /home/r/src/rust/miri/src/shims/foreign_items.rs:70:15
  21:     0x555edd45cd32 - miri::shims::foreign_items::EvalContextExt::emulate_dyn_sym::h7c8bf4929d2facaa
                               at /home/r/src/rust/miri/src/shims/foreign_items.rs:116:19
  22:     0x555edd45cd32 - <miri::machine::MiriMachine as rustc_const_eval::interpret::machine::Machine>::call_extra_fn::h62266b16902a7c52
                               at /home/r/src/rust/miri/src/machine.rs:1047:9
  23:     0x555edd45cd32 - rustc_const_eval::interpret::call::<impl rustc_const_eval::interpret::eval_context::InterpCx<M>>::init_fn_call::h245df811d6a6bdb1
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_const_eval/src/interpret/call.rs:503:24
  24:     0x555edd4a0675 - rustc_const_eval::interpret::step::<impl rustc_const_eval::interpret::eval_context::InterpCx<M>>::eval_terminator::hc2ef04b3c3f03654
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_const_eval/src/interpret/step.rs:499:17
  25:     0x555edd4a0675 - rustc_const_eval::interpret::step::<impl rustc_const_eval::interpret::eval_context::InterpCx<M>>::step::hb8cfa401d0460911
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_const_eval/src/interpret/step.rs:64:9
  26:     0x555edd4a0675 - miri::concurrency::thread::EvalContextExt::run_threads::h7f521563a972fcfc
                               at /home/r/src/rust/miri/src/concurrency/thread.rs:1202:25
  27:     0x555edd431a1e - miri::eval::eval_entry::{{closure}}::h50cd843290769473
                               at /home/r/src/rust/miri/src/eval.rs:454:49
  28:     0x555edd431a1e - core::ops::function::FnOnce::call_once::hf0ddbdd5fc04a2ad
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/library/core/src/ops/function.rs:250:5
  29:     0x555edd431a1e - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h25fda25cbf1dbadf
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/library/core/src/panic/unwind_safe.rs:272:9
  30:     0x555edd431a1e - std::panicking::try::do_call::h09d1ac5000eb7d6b
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/library/std/src/panicking.rs:557:40
  31:     0x555edd431a1e - std::panicking::try::h4637f2d8f781d1ad
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/library/std/src/panicking.rs:520:19
  32:     0x555edd431a1e - std::panic::catch_unwind::hde04fbee56566f21
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/library/std/src/panic.rs:348:14
  33:     0x555edd431a1e - miri::eval::eval_entry::hcddf6bff9a40d881
                               at /home/r/src/rust/miri/src/eval.rs:454:9
  34:     0x555edd3a3c1e - <miri::MiriCompilerCalls as rustc_driver_impl::Callbacks>::after_analysis::{{closure}}::hcbd495526e31cfe4
                               at /home/r/src/rust/miri/src/bin/miri.rs:118:40
  35:     0x555edd3a3c1e - rustc_middle::ty::context::GlobalCtxt::enter::{{closure}}::hb075e3a78fe3aaa1
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_middle/src/ty/context.rs:1324:37
  36:     0x555edd3a3c1e - rustc_middle::ty::context::tls::enter_context::{{closure}}::h6a7a72760ded75e0
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_middle/src/ty/context/tls.rs:82:9
  37:     0x555edd3a3c1e - std::thread::local::LocalKey<T>::try_with::h4f3ae6497c08df6a
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/library/std/src/thread/local.rs:283:12
  38:     0x555edd3a3c1e - std::thread::local::LocalKey<T>::with::h7927f8c94c8fb2f9
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/library/std/src/thread/local.rs:260:9
  39:     0x555edd3a3c1e - rustc_middle::ty::context::tls::enter_context::h073c2b7b7da84baa
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_middle/src/ty/context/tls.rs:79:9
  40:     0x555edd3a3c1e - rustc_middle::ty::context::GlobalCtxt::enter::h71a5b814611e500a
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_middle/src/ty/context.rs:1324:9
  41:     0x555edd3ac7d9 - rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>::enter::h3ad777f729b4fcb5
                               at /rustc/76ed7a1fa40c3f54d3fd3f834e12bf9c932d0146/compiler/rustc_interface/src/queries.rs:65:9
  42:     0x555edd3ac7d9 - <miri::MiriCompilerCalls as rustc_driver_impl::Callbacks>::after_analysis::haba065accbc74488
                               at /home/r/src/rust/miri/src/bin/miri.rs:82:9
  43:     0x7f3c57b2d51f - rustc_interface[97bbde118ee087ca]::interface::run_compiler::<core[70a0c212498bdbf2]::result::Result<(), rustc_span[3745e46e84edc9e8]::ErrorGuaranteed>, rustc_driver_impl[7b961fc7fcd0c978]::run_compiler::{closure#0}>::{closure#1}
  44:     0x7f3c57bb5390 - std[dac38a4e0a05c6f4]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[97bbde118ee087ca]::util::run_in_thread_with_globals<rustc_interface[97bbde118ee087ca]::util::run_in_thread_pool_with_globals<rustc_interface[97bbde118ee087ca]::interface::run_compiler<core[70a0c212498bdbf2]::result::Result<(), rustc_span[3745e46e84edc9e8]::ErrorGuaranteed>, rustc_driver_impl[7b961fc7fcd0c978]::run_compiler::{closure#0}>::{closure#1}, core[70a0c212498bdbf2]::result::Result<(), rustc_span[3745e46e84edc9e8]::ErrorGuaranteed>>::{closure#0}, core[70a0c212498bdbf2]::result::Result<(), rustc_span[3745e46e84edc9e8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[70a0c212498bdbf2]::result::Result<(), rustc_span[3745e46e84edc9e8]::ErrorGuaranteed>>
  45:     0x7f3c57bb59fa - <<std[dac38a4e0a05c6f4]::thread::Builder>::spawn_unchecked_<rustc_interface[97bbde118ee087ca]::util::run_in_thread_with_globals<rustc_interface[97bbde118ee087ca]::util::run_in_thread_pool_with_globals<rustc_interface[97bbde118ee087ca]::interface::run_compiler<core[70a0c212498bdbf2]::result::Result<(), rustc_span[3745e46e84edc9e8]::ErrorGuaranteed>, rustc_driver_impl[7b961fc7fcd0c978]::run_compiler::{closure#0}>::{closure#1}, core[70a0c212498bdbf2]::result::Result<(), rustc_span[3745e46e84edc9e8]::ErrorGuaranteed>>::{closure#0}, core[70a0c212498bdbf2]::result::Result<(), rustc_span[3745e46e84edc9e8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[70a0c212498bdbf2]::result::Result<(), rustc_span[3745e46e84edc9e8]::ErrorGuaranteed>>::{closure#1} as core[70a0c212498bdbf2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  46:     0x7f3c57bb5daf - std::sys::pal::unix::thread::Thread::new::thread_start::hc81315a30d1417be
  47:     0x7f3c59274732 - start_thread
                               at ./nptl/pthread_create.c:447:8
  48:     0x7f3c592ef2b8 - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
  49:                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 make sure that you have updated to the latest nightly

note: rustc 1.83.0-nightly (76ed7a1fa 2024-09-26) running on x86_64-unknown-linux-gnu

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
  --> /home/r/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.1.16/src/solaris_illumos.rs:37:17
   |
37 |                 func(buf.as_mut_ptr(), buf.len(), 0) as libc::ssize_t
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: BACKTRACE:
   = note: inside closure at /home/r/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.1.16/src/solaris_illumos.rs:37:17: 37:53
   = note: inside `getrandom::util_libc::sys_fill_exact::<{closure@getrandom::imp::getrandom_inner::{closure#0}}>` at /home/r/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.1.16/src/util_libc.rs:58:19: 58:32
   = note: inside `getrandom::imp::getrandom_inner` at /home/r/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.1.16/src/solaris_illumos.rs:36:13: 38:15
   = note: inside `getrandom::getrandom` at /home/r/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.1.16/src/lib.rs:291:5: 291:31
note: inside `main`
  --> tests/pass-dep/getrandom.rs:9:5
   |
9  |     getrandom_01::getrandom(&mut data).unwrap();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: inside `<fn() as std::ops::FnOnce<()>>::call_once - shim(fn())` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5: 250:71
   = note: inside `std::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs:154:18: 154:21
   = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:164:18: 164:75
   = 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/r/.rustup/toolchains/miri/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/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:557:40: 557:43
   = note: inside `std::panicking::r#try::<i32, &dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:520:19: 520:88
   = note: inside `std::panic::catch_unwind::<&dyn std::ops::Fn() -> i32 + std::marker::Sync + std::panic::RefUnwindSafe, i32>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panic.rs:348:14: 348:33
   = note: inside closure at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:143:48: 143:73
   = note: inside `std::panicking::r#try::do_call::<{closure@std::rt::lang_start_internal::{closure#2}}, isize>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:557:40: 557:43
   = note: inside `std::panicking::r#try::<isize, {closure@std::rt::lang_start_internal::{closure#2}}>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panicking.rs:520:19: 520:88
   = note: inside `std::panic::catch_unwind::<{closure@std::rt::lang_start_internal::{closure#2}}, isize>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/panic.rs:348:14: 348:33
   = note: inside `std::rt::lang_start_internal` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:143:20: 143:98
   = note: inside `std::rt::lang_start::<()>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/rt.rs:163:17: 168:6

warning: 1 warning emitted

error: test failed, to rerun pass `--test ui`

Caused by:
  process didn't exit successfully: `/home/r/src/rust/miri/target/debug/deps/ui-95447b71e6934454 --miri-run-dep-mode --edition 2021 --sysroot /home/r/.cache/miri tests/pass-dep/getrandom.rs` (exit status: 1)
Error: command exited with non-zero code `cargo +miri test --manifest-path /home/r/src/rust/miri/./Cargo.toml --test ui --quiet -- --miri-run-dep-mode --edition 2021 --sysroot /home/r/.cache/miri tests/pass-dep/getrandom.rs`: 1

Interestingly, it works fine on Illumos.

The backtrace points at this line

this.write_scalar(Scalar::from_target_usize(len, this), dest)?;

My first guess is this might be related to #3842 -- some argument type mismatches can cause ICEs. And strangely, getrandom does use a different signature for this function for Solaris and Illumos:

#[cfg(target_os = "illumos")]
type GetRandomFn = unsafe extern "C" fn(*mut u8, libc::size_t, libc::c_uint) -> libc::ssize_t;
#[cfg(target_os = "solaris")]
type GetRandomFn = unsafe extern "C" fn(*mut u8, libc::size_t, libc::c_uint) -> libc::c_int;

What is the true signature?

Cc @devnexen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions