madsim-rs / madsim

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

fix(madsim): fix determinism for getrandom #202

Closed wangrunji0408 closed 3 months ago

wangrunji0408 commented 3 months ago

This PR fixes #201, a bug happening on Linux only. The reason why getrandom yields a different value in the first run is that, a getrandom(0, 0) is called on first access to check the availability of this function (code). It mutates the global random state by mistake. This PR adds a branch to avoid the mutation.

release as madsim v0.2.27