unsafeness of unsafeInterleaveIO
Thomas Jäger
thjaeger at gmail.com
Fri Jun 10 19:55:57 EDT 2005
> Just looking at the documentation for System.IO.unsafeInterleaveIO,
> what exactly is unsafe about it?
It can create "pure values" that trigger side effects during their
evaluation. This can be abused to do IO outside of an IO monad
(actually, hGetContents can already be used for that purpose).
In the worst case, it can even crash the RTS:
> import Control.Concurrent.STM
> import System.IO.Unsafe
>
> main :: IO ()
> main = atomically =<< unsafeInterleaveIO (atomically $ return $ return ())
Thomas
More information about the Glasgow-haskell-users
mailing list