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:
```hs
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.
<details><summary>Trac metadata</summary>
| 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 | |
</details>
<!-- {"blocked_by":[],"summary":"hPutBuf crashes when trying to write a large string to stdout (resource exhausted)","status":"New","operating_system":"","component":"libraries/base","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.8.3","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":["ekmett","hvr"],"type":"Bug","description":"The following program crashes when I try to write a byte string larger than 61kb to stdout: \r\n\r\n{{{#!hs\r\nimport qualified Data.ByteString.Char8 as BS\r\n\r\nmain = BS.putStrLn $ BS.replicate (62 * 1024) 'x'\r\n}}}\r\n\r\nWhen I run the above, I get the following runtime error: \r\n{{{\r\n<stdout>: hPutBuf: resource exhausted (Not enough space)\r\n}}}\r\n\r\nGHC versions tested: 7.6.3 and 7.8.3 (both 32 and 64 bit)\r\nOS: Windows 7 and Windows Server 20008R2\r\n\r\nThe 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.\r\n\r\nNote: The Linux version of the program was tested with GHC 7.6.3 because this is the one I have on my Ubuntu machine. ","type_of_failure":"OtherFailure","blocking":[]} -->
issue