Skip to content

Lazy I/O and asynchronous exceptions don't mix well

This program:

import Control.Concurrent
import Control.Exception

main = do
  s <- getContents
  t <- forkIO $ evaluate (length s) >> return ()
  threadDelay 1000
  killThread t
  print (length s)

results in

$ ./async            
async: thread killed

when really it should just wait for input.

The problem is #2558 (closed), but since I'm not sure that #2558 (closed) has a general solution (see comments on that ticket) I thought I'd open a ticket for this specific case. It's amazing nobody has complained about this before.

Trac metadata
Trac field Value
Version 6.12.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information