[GHC] #5257: Calling fail on a UTF-8 encoded string (in file) causes garbage to be printed

GHC cvs-ghc at haskell.org
Wed Jun 15 11:29:35 CEST 2011


#5257: Calling fail on a UTF-8 encoded string (in file) causes garbage to be
printed
------------------------------------------+---------------------------------
  Reporter:  anthony.de.almeida.lopes     |          Owner:                
      Type:  bug                          |         Status:  closed        
  Priority:  normal                       |      Milestone:                
 Component:  Runtime System               |        Version:  7.0.2         
Resolution:  fixed                        |       Keywords:                
  Testcase:                               |      Blockedby:                
Difficulty:                               |             Os:  Linux         
  Blocking:                               |   Architecture:  x86_64 (amd64)
   Failure:  Incorrect result at runtime  |  
------------------------------------------+---------------------------------
Changes (by simonmar):

  * status:  new => closed
  * resolution:  => fixed


Old description:

> For example,
>
> guerrilla at delta:/tmp/foo$ cat Test.hs
> module Main where
>
> main :: IO ()
> main =
>     do
>         putStrLn "μ"
>         fail "μ"
> guerrilla at delta:/tmp/foo$ ./Test
> μ
> Test: user error (�)
> guerrilla at delta:/tmp/foo$ ./Test 2>&1 | xxd
> 0000000: cebc 0a54 6573 743a 2075 7365 7220 6572  ...Test: user er
> 0000010: 726f 7220 28bc 290a                      ror (.).
>

> Using either encodeString or writing it in escaped hexidecimal does work.

New description:

 For example,
 {{{
 guerrilla at delta:/tmp/foo$ cat Test.hs
 module Main where

 main :: IO ()
 main =
     do
         putStrLn "μ"
         fail "μ"
 guerrilla at delta:/tmp/foo$ ./Test
 μ
 Test: user error (�)
 guerrilla at delta:/tmp/foo$ ./Test 2>&1 | xxd
 0000000: cebc 0a54 6573 743a 2075 7365 7220 6572  ...Test: user er
 0000010: 726f 7220 28bc 290a                      ror (.).
 }}}

 Using either encodeString or writing it in escaped hexidecimal does work.

--

Comment:

 Fixed in 7.2.1, thanks to Max's work on Unicode.  (the problem was that
 the main exception handler converts the exception to a String and then
 passes it to the RTS error function using `withCString`, which until
 recently did no decoding).

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



More information about the Glasgow-haskell-bugs mailing list