Skip to content

Apparently deadlock in write to closed handle

@hvr reported that the following program non-deterministically hang:

import System.IO

main :: IO ()
main = do
  hPutChar stderr 'A' -- unbuffered
  hPutChar stdout 'X' -- buffered -- will indeterministically cause delayed lock-ups
  hPutChar stderr 'Z' -- unbuffered
  hPutChar stderr '\n' -- unbuffered
$ ghc -threaded -O Main.hs
$ while :; do ./Main >&- ; done
AZ
AZ
*hang*

I can confirm that the program hangs almost immediately on Linux with GHC 9.2.8, 9.6.3, and 9.8.1. @hvr says that the issue may have been introduced in GHC 8.2.1.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information