[GHC] #10731: System.IO.openTempFile is not thread safe on Windows

GHC ghc-devs at haskell.org
Tue Aug 4 10:20:33 UTC 2015


#10731: System.IO.openTempFile is not thread safe on Windows
-------------------------------------+-------------------------------------
        Reporter:  NeilMitchell      |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  normal            |               Milestone:
       Component:  libraries/base    |                 Version:  7.10.1
      Resolution:                    |                Keywords:
Operating System:  Windows           |            Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Runtime crash     |               Test Case:
      Blocked By:                    |                Blocking:
 Related Tickets:                    |  Differential Revisions:
-------------------------------------+-------------------------------------

Comment (by NeilMitchell):

 I've avoided this issue in the extra package
 (https://github.com/ndmitchell/extra/blob/master/src/System/IO/Extra.hs)
 with three techniques:

 * To avoid races within a process, I have a single IORef which I increment
 to find unique names. That guarantees that a process will never clash with
 itself.
 * To help avoid cross-process races I start that IORef at a random
 starting point (using the start time plus Process Id would be ideal, but I
 couldn't get that easily, so I use the time).
 * If all else fails, I retry up to 5 times on IO errors.

 With those features, I've yet to get a failure.

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


More information about the ghc-tickets mailing list