Date: Tue, 02 Jul 2013 19:44:49 +0400 From: Andrey Chernov <ache@freebsd.org> To: Bruce Evans <brde@optusnet.com.au> Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, "Pedro F. Giffuni" <pfg@FreeBSD.org>, src-committers@FreeBSD.org Subject: Re: RAND_MAX broken Message-ID: <51D2F571.8050108@freebsd.org> In-Reply-To: <20130702165642.X1571@besplex.bde.org> References: <201307012143.r61Lhemi067176@svn.freebsd.org> <20130702130818.V865@besplex.bde.org> <20130702165642.X1571@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 02.07.2013 11:39, Bruce Evans wrote: > The bugs are a little different than I said above. There is no overflow > problem and no problem with invalid values being produces, since the > algorithm from ACM is careful to do everything with 32 bit signed > integers without causing overflow. The algorithm just doesn't produce > values mod 2**32 as expected by all the functions. It does what it > claims to do -- it produces values mod (2**32 - 1). The largest bug > is that RAND_MAX is off by 1. It is specified as the largest value > returned by rand(), but in FreeBSD rand() never returns it unless > USE_WEAK_SEEDING is confgured. The values should be unifornly > distributed on average beteen 0 and RAND_MAX,but that is impossible > if RADND_MAX is never returned. From libc/stdlib/srand.c: Don't ever consider USE_WEAK_SEEDING defined - result is distributet _very_ poorly and the code should be removed long time ago. BTW, I don't understand well fixes you suggest. Is it to define RAND_MAX as 0x7ffffffe ? -- http://ache.vniz.net/ bitcoin:13fGiNutKNHcVSsgtGQ7bQ5kgUKgEQHn7N
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51D2F571.8050108>