System.Random - bugs? or am I just confused?
Bas van Dijk
v.dijk.bas at gmail.com
Thu Jul 18 22:16:57 CEST 2013
On 17 July 2013 19:00, Hans Georg Schaathun
<georg+haskellib at schaathun.net> wrote:
> Hi all,
>
> I have been digging into the System.Random module lately.
> Initially, I was concerned about the split method, but trying
> to understand the code and algorithm, there are a couple of
> other issues that bother me. I hope this is the right forum
> to ask about them ...
Hi Hans, no comments on your issues yet. I just wanted to report an
issue in random I discovered 3 months ago. This is the message I send
to Ryan:
> My colleague (Utkarsh Upadhyay) got a stack-overflow in a program he
> was working on. Thomas Schilling and me traced it down to randomRs
> being to lazy which causes the following to generate a stack-overflow
> exception:
>
> g <- getStdGen
> randomRs (0,10::Int) g !! 1000000
>
> The attached patch fixes the bug. I also included a patch to UNPACK
> the Int32 fields into the StdGen constructor.
I added the patches to the following gist:
https://gist.github.com/basvandijk/6032630
Cheers,
Bas
More information about the Libraries
mailing list