writeFile/readFile on multiple threads leads to error

Claus Reinke claus.reinke at talk21.com
Wed Apr 22 08:56:40 EDT 2009


> do print ("READ START",x) ; res <- readFile x ; print ("READ STOP",x)
> ; return res

Unless you've defined your own version of 'readFile', to mean read
entire file now, the first 'print' is optimistic and the second 'print' is a lie.

Claus

> do print ("WRITE START",x); writeFile x src ; print ("WRITE STOP",x)
> 
> I then get on the console:
> 
> WRITE START foo
> WRITE STOP foo
> READ START foo
> openFile doesn't have permission to open foo.
> 
> 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.
> 
> I'm happy to supply more details if you can think of anything that will help,
> 
> Thanks
> 
> Neil
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


More information about the Glasgow-haskell-users mailing list