>> I have many threads, which read and write files. Every so often one >> thread will write a file, then another thread will read the same file >> - but fail during the open call. There are locks to ensure that the >> write call finishes before the read call begins. I modified the code >> to give: >> >> The writeFile/readFile are happening in different threads, and they >> usually succeed - but not always. The bug seems to go away when I add >> performGC just after writeFile. My guess is that something in the >> openFile/hClose pair isn't really closed until a garbage collection >> happens. All this is using GHC 6.10.2 on XP through Cygwin. > > The hClose really does close the file descriptor. The only thing left > is the finalizer, but it is just a no-op on an already-closed Handle. > > I can't think of anything we're doing that could possibly cause this, > but I have seen rogue "permission denied" errors on Windows from time > to time, they're quite annoying. Here's a possibly-related ticket: > > http://hackage.haskell.org/trac/ghc/ticket/2924
I've added information from this thread to that ticket. It looks suspiciously similar, and I have a feeling that some combination of writeFile/readFile in a similar pattern might invoke the same issue - it's certainly quite close to the behaviour of my application. > You might want to run the process under ProcMon and see if you can > figure out what's going on (if you can bear to use ProcMon, it's a > very poor replacement for strace IMO). I tried and the bug goes away, plus the computer grinds to a crunching halt. The bug is very sensitive, and with the speed loss associated with ProcMon probably disappears on its own. No useful information can be obtained there. Thanks Neil _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users