[GHC] #10940: Random number chosen by openTempFile is always 1804289383846930886

GHC ghc-devs at haskell.org
Wed Oct 7 21:43:27 UTC 2015


#10940: Random number chosen by openTempFile is always 1804289383846930886
-------------------------------------+-------------------------------------
        Reporter:  andersk           |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  libraries/base    |              Version:  7.10.2
      Resolution:                    |             Keywords:
Operating System:  Linux             |         Architecture:
 Type of failure:  Incorrect result  |  Unknown/Multiple
  at runtime                         |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #9058             |  Differential Rev(s):
-------------------------------------+-------------------------------------

Comment (by slyfox):

 I agree it's a problem.

 Posting '''ghc-7.8.4''' results for comparison:
 {{{
 $ runhaskell a.hs
 "/tmp/47"
 $ runhaskell a.hs
 "/tmp/59"
 $ runhaskell a.hs
 "/tmp/71"
 $ runhaskell a.hs
 "/tmp/83"
 $ runhaskell a.hs
 "/tmp/95"
 $ runhaskell a.hs
 "/tmp/107"
 }}}
 (nice +12 steps)

 The question is what to use so it would work on modern systems.

 I see the following routes:

 1. use something portable and insecure like seeding with
 '''srand(time())''': will not behave nicely after '''fork()''' from
 haskell program, still predictable
 2. introduce OS-specific branches to use '''mkstemp''' / '''mkostemp''' /
 '''mkostemps''' / '''GetTempFileName''' / '''GetTempPath'''.

 Is there a nicer way?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10940#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list