Skip to content

Deadlock in non-threaded RTS with hPutBuf

Using the non-threaded RTS, the attached program works fine in 6.8.2, but deadlocks in 6.8.3 and later GHCs (including 6.10.3 and 6.11.20090618).

The program forks (runInteractiveProcess) two copies of cat, then forks off two separate threads (forkIO) to write a large buffer to stdin of each copy, and also lazily reads the outputs of each copy of cat, forcing the results with an equality test.

From strace, it looks like 6.8.2 is correctly selecting on multiple FDs at once (though just 3, rather than all 4, which I don't understand), whereas 6.8.3 doesn't and hence ends up in a deadlock when the pipe it wants to use blocks while some other pipe is actually ready.

Trac metadata
Trac field Value
Version 6.8.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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