Skip to content

hPutBuf crashes when trying to write a large string to stdout (resource exhausted)

The following program crashes when I try to write a byte string larger than 61kb to stdout:

import qualified Data.ByteString.Char8 as BS

main = BS.putStrLn $ BS.replicate (62 * 1024) 'x'

When I run the above, I get the following runtime error:

<stdout>: hPutBuf: resource exhausted (Not enough space)

GHC versions tested: 7.6.3 and 7.8.3 (both 32 and 64 bit) OS: Windows 7 and Windows Server 20008R2

The issue is not reproducible with the Linux version of GHC. It is also not reproducible if I use the Lazy variant of the byte strings.

Note: The Linux version of the program was tested with GHC 7.6.3 because this is the one I have on my Ubuntu machine.

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