[GHC] #679: using ReadWriteMode in Windows corrupts files

GHC trac at galois.com
Mon Jan 30 13:10:35 EST 2006


#679: using ReadWriteMode in Windows corrupts files
-------------------------------+--------------------------------------------
    Reporter:  aljee at hyper.cx  |        Owner:         
        Type:  bug             |       Status:  new    
    Priority:  normal          |    Milestone:         
   Component:  libraries/base  |      Version:  6.4.1  
    Severity:  normal          |     Keywords:         
          Os:  Windows         |   Difficulty:  Unknown
Architecture:  Unknown         |  
-------------------------------+--------------------------------------------
In Windows, running the following program makes test.txt corrupted.
 {{{
 import System.IO
 main = do
   h <- openFile "test.txt" ReadWriteMode
   hGetLine h
   hPutStrLn h "yz"
   hClose h
 }}}
 Initial content of test.txt is:
 {{{
 ab
 cd
 ef
 gh
 }}}
 Expected content of test.txt after the excution is:
 {{{
 ab
 yz
 ef
 gh
 }}}
 Actual result is(in hex):

 61 62 0d 0a 63 64 0d 79 7a 0d 0a 0a 67 68 0d 0a

 I think that the problem is that GHC.Handle.flushReadBuffer does not
 calculate the correct amount of seek to be done.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/679>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list