
#10731: System.IO.openTempFile is not thread safe on Windows -------------------------------------+------------------------------------- Reporter: | Owner: NeilMitchell | Type: bug | Status: new Priority: normal | Milestone: Component: | Version: 7.10.1 libraries/base | Keywords: | Operating System: Windows Architecture: | Type of failure: Runtime crash Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- Given the test program: {{{#!hs import Control.Concurrent import System.IO import Control.Monad import System.Directory main = do putStrLn "Starting" var <- newEmptyMVar tdir <- getTemporaryDirectory xs <- replicateM 10 $ do var <- newEmptyMVar flip forkFinally (\s -> do print s; putMVar var ()) $ do replicateM_ 100000 $ do (file, h) <- openTempFile tdir "test.txt" hClose h removeFile file return var mapM_ takeMVar xs }}} If I compile and run that with {{{ghc --make TmpFile.hs -threaded && tmpfile +RTS -N5}}} I get: {{{ Starting Left C:\Users\NDMIT_~1\AppData\Local\Temp\: openTempFile: permission denied (Permission denied) Left C:\Users\NDMIT_~1\AppData\Local\Temp\: openTempFile: permission denied (Permission denied) ... }}} I've reproduced this on GHC 7.8 and 7.10.1. We hit this in production about twice a day. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10731 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler