madsim-rs / madsim

Magical Deterministic Simulator for distributed systems in Rust.
Apache License 2.0
662 stars 48 forks source link

unaligned pointer for rand #205

Closed xxchan closed 5 months ago

xxchan commented 5 months ago
thread '<unnamed>' panicked at library/core/src/panicking.rs:215:5:
unsafe precondition(s) violated: ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null and the specified memory ranges do not overlap
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a07f3eb43acc5df851e15176c7081a900a30a4d7/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_nounwind_fmt::runtime
             at /rustc/a07f3eb43acc5df851e15176c7081a900a30a4d7/library/core/src/panicking.rs:110:18
   2: core::panicking::panic_nounwind_fmt
             at /rustc/a07f3eb43acc5df851e15176c7081a900a30a4d7/library/core/src/panicking.rs:120:5
   3: core::panicking::panic_nounwind
             at /rustc/a07f3eb43acc5df851e15176c7081a900a30a4d7/library/core/src/panicking.rs:215:5
   4: core::intrinsics::copy::precondition_check
             at /rustc/a07f3eb43acc5df851e15176c7081a900a30a4d7/library/core/src/ub_checks.rs:66:21
   5: core::intrinsics::copy
             at /rustc/a07f3eb43acc5df851e15176c7081a900a30a4d7/library/core/src/intrinsics.rs:2989:9
   6: getrandom
             at /risingwave/.cargo/registry/src/index.crates.io-6f17d22bba15001f/madsim-0.2.22/src/sim/rand.rs:212:9
   7: getrandom::imp::is_getrandom_available
             at /risingwave/.cargo/git/checkouts/getrandom-dec8fd0f1dd9e7e6/e79a7ae/src/linux_android.rs:30:24
   8: core::ops::function::FnOnce::call_once
wangrunji0408 commented 5 months ago

I believe this issue has been fixed by #202 (included in v0.2.27) as I see is_getrandom_available in the backtrace. However, #202 is still problematic if the buf argument passed to getrandom is not 8-bytes aligned. This will be fixed in #206.