Commit 6f32757e authored by ian@well-typed.com's avatar ian@well-typed.com
Browse files

Handle UTF8 correctly in GHC.Conc.labelThread; fixes #6010

parent a66b6ff0
...@@ -113,12 +113,14 @@ import GHC.Base ...@@ -113,12 +113,14 @@ import GHC.Base
import {-# SOURCE #-} GHC.IO.Handle ( hFlush ) import {-# SOURCE #-} GHC.IO.Handle ( hFlush )
import {-# SOURCE #-} GHC.IO.Handle.FD ( stdout ) import {-# SOURCE #-} GHC.IO.Handle.FD ( stdout )
import GHC.IO import GHC.IO
import GHC.IO.Encoding.UTF8
import GHC.IO.Exception import GHC.IO.Exception
import GHC.Exception import GHC.Exception
import qualified GHC.Foreign
import GHC.IORef import GHC.IORef
import GHC.MVar import GHC.MVar
import GHC.Ptr
import GHC.Real ( fromIntegral ) import GHC.Real ( fromIntegral )
import GHC.Pack ( packCString# )
import GHC.Show ( Show(..), showString ) import GHC.Show ( Show(..), showString )
import GHC.Weak import GHC.Weak
...@@ -427,10 +429,10 @@ Other applications like the graphical Concurrent Haskell Debugger ...@@ -427,10 +429,10 @@ Other applications like the graphical Concurrent Haskell Debugger
-} -}
labelThread :: ThreadId -> String -> IO () labelThread :: ThreadId -> String -> IO ()
labelThread (ThreadId t) str = IO $ \ s -> labelThread (ThreadId t) str =
let !ps = packCString# str GHC.Foreign.withCString utf8 str $ \(Ptr p) ->
!adr = byteArrayContents# ps in IO $ \ s ->
case (labelThread# t adr s) of s1 -> (# s1, () #) case labelThread# t p s of s1 -> (# s1, () #)
-- Nota Bene: 'pseq' used to be 'seq' -- Nota Bene: 'pseq' used to be 'seq'
-- but 'seq' is now defined in PrelGHC -- but 'seq' is now defined in PrelGHC
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment