unprotected use of global variables in base:GHC.IO.Encoding
nicolas.frisby at gmail.com
Sun Feb 17 17:41:08 CET 2013
I've noticed some suspicious code in base:GHC.IO.Encoding.
setLocaleEncoding, setFileSystemEncoding, setForeignEncoding ::
TextEncoding -> IO ()
(getLocaleEncoding, setLocaleEncoding) = mkGlobal initLocaleEncoding
(getFileSystemEncoding, setFileSystemEncoding) = mkGlobal
(getForeignEncoding, setForeignEncoding) = mkGlobal
mkGlobal :: a -> (IO a, a -> IO ())
mkGlobal x = unsafePerformIO $ do
x_ref <- newIORef x
return (readIORef x_ref, writeIORef x_ref)
I've not elided any pragmas and there's no relevant LANGUAGE or OPTIONS
With HEAD from a couple weeks ago, mkGlobal is not getting inlined. But
with some of my experimental alterations of sizeExpr, it is getting inlined.
So this code should probably have some of the guards for faking global
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs