Odd interaction between unsafePerformIO and threadDelay
Summary
threadDelay
doesn't seem to resume properly after an exception in an unsafePerformIO
context.
Steps to reproduce
ghci -threaded
> import Control.Concurrent
> import System.IO.Unsafe
> import Control.Exception
> let okay = unsafePerformIO (evaluate (sum [1..10^7]) *> putStrLn "Hi there.")
> okay
-- Hit Ctrl-C
-- See "^CInterrupted."
> okay
-- After a few seconds, it prints "Hi there." and then "()".
> let oops = unsafePerformIO (threadDelay (10^7) *> putStrLn "Hi there.")
> oops
-- Hit Ctrl-C
-- See "^CInterrupted."
> oops
-- See "^CInterrupted."
Expected behavior
I would expect the threadDelay
call to resume, and to eventually see "Hi there." and the ()
return value.
Environment
- GHC version used: 9.0.1
Optional:
- Operating System: Linux (OpenSUSE)
- System Architecture: x86_64