System.Random - bugs? or am I just confused?

Edward Kmett ekmett at gmail.com
Thu Jul 18 22:55:07 CEST 2013


I definitely agree that the StdGen fields should be unpacked.

The slightly stricter evaluation of the randomRs generator seems like the
right solution as well.

-Edward

On Thu, Jul 18, 2013 at 4:16 PM, Bas van Dijk <v.dijk.bas at gmail.com> wrote:

> 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
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20130718/86ec58c5/attachment.htm>


More information about the Libraries mailing list