Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 02 Feb 2003 19:08:47 +0000
From:      Mark Murray <mark@grondar.org>
To:        Bakul Shah <bakul@bitblocks.com>
Cc:        "Jeroen C. van Gelderen" <jeroen@vangelderen.org>, phk@FreeBSD.ORG, current@FreeBSD.ORG
Subject:   Re: rand() is broken 
Message-ID:  <200302021908.h12J8laX050048@grimreaper.grondar.org>
In-Reply-To: Your message of "Sun, 02 Feb 2003 10:48:00 PST." <200302021848.NAA19508@agamemnon.cnchost.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
Bakul Shah writes:
> > Good point. We can re-implement random() internally with arc4rand().
> > 
> > Objections?
> 
> Guys, please realize that random() is also used in generating
> simulation inputs (or timing or whatever).  If you go change
> the underlying algorithm or its parameters one can't generate
> the same sequence from the same seed when repeating a test.
> Some chip bug symptoms show up after hours/days of simulation
> time and only with specific inputs so repeatablity is a
> requirement.

RC4 is _utterly_ repeatable, given a particular seed/key.

> The old 16 bit rand() was broken enough that it didn't matter
> much (read: _I_ don't care) if its behavior got changed but
> random() has a pretty long cycle and enough "randomness" to
> be very useful and it *is* used.

Yes. And it breaks, and we have a complainant.

> *Please* don't change random() -- if you do that you will
> break existing tests.  It is not a matter of just rewriting
> tests since there is no easy way to predict  which input
> triggers a certain bug -- one can try to use the same
> binaries but that prevents fixing of bugs in the test
> generation code itself.

Heisenbug. Which tests do we break? Tests for specific output,
or tests for more general cases?

The random() function in libc is documented to give the same
pseudo-random output for a particular seed. if you link your
program against a _different_ libc, you cannot expect your
results to follow a particular number sequence. We have to
be able to fix bugs, and a bug has been identified. If you
want a stable generator here, link statically, and keep a
set of compatiblity libraries around.

> If you think random() is not random enough for your purposes,
> go create a new function with a *new* name.

Any supporters of this request?

> [I see from his latest email that PHK remembered the old
> discussion!]

So did I!

M
--
Mark Murray
iumop ap!sdn w,I idlaH

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200302021908.h12J8laX050048>