segfault when ignoring invalid byte sequence when decoding UTF8//IGNORE
|Reported by:||ganesh||Owned by:||batterseapower|
|Type of failure:||Runtime crash||Test Case:|
|Related Tickets:||Differential Rev(s):|
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 ) h <- openFile tempFile ReadMode hSetEncoding h utf8Ignore hGetContents h >>= putStrLn