Date: Wed, 2 Dec 2020 23:53:41 +0200 From: Andriy Gapon <avg@FreeBSD.org> To: FreeBSD Current <freebsd-current@FreeBSD.org> Cc: "Conrad E. Meyer" <cem@FreeBSD.org> Subject: rand() is racy in multi-threaded programs? Message-ID: <5b827768-eb46-07f3-5b44-49627779786e@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
Specifically, concurrent "first" calls to rand(). There can be a moment when rand3_state is allocated but not completely set up with initstate_r(). Is this a known / documented issue? Should we try to do better? P.S. I am seeing this issue from time to time when running ztest program (from ZFS). I guess that it uses rand() just because that's what OpenZFS did / does on illumos and Linux. P.P.S. Just realized that the problem can be relatively recent. https://svnweb.freebsd.org/base?view=revision&revision=357382 -- Andriy Gapon
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5b827768-eb46-07f3-5b44-49627779786e>