#7522: segfault when ignoring invalid byte sequence when decoding UTF8//IGNORE
Reporter:  ganesh            |          Owner:                  
    Type:  bug               |         Status:  new             
Priority:  normal            |      Component:  Compiler        
 Version:  7.6.1             |       Keywords:                  
      Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
 Failure:  Runtime crash     |      Blockedby:                  
Blocking:                    |        Related:                  
 The code below segfaults on a variety of platforms and GHC versions - I've
 tried 7.4.1 and 7.6.1, on Windows and Linux.

 It seems to be related to (a) the specific choice of UTF8 - doesn't happen
 with UTF16 or UTF32 etc and (b) having the invalid byte sequence at the
 end of the thing being decoded.

 import qualified Data.ByteString as B
 import System.IO

 tempFile = "temp"

 main = do
    utf8Ignore <- mkTextEncoding "UTF8//IGNORE"
    B.writeFile tempFile (B.pack [128])
    h <- openFile tempFile ReadMode
    hSetEncoding h utf8Ignore
    hGetContents h >>= putStrLn

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

Glasgow-haskell-bugs mailing list

Reply via email to