summaryrefslogtreecommitdiff
path: root/libraries/base/tests/all.T
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-07-19 14:58:23 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-07-23 21:08:05 -0400
commit509445b5947ce85499672399f5e88b6196af4c5a (patch)
tree167870cdb6526452cc5156d6f75c3294c17e70bc /libraries/base/tests/all.T
parent4beb12dbc4a7c42c3967dd51da769a3346192a1b (diff)
downloadhaskell-509445b5947ce85499672399f5e88b6196af4c5a.tar.gz
Check the buffer size *before* calling the continuation in withEncodedCString
This fixes a very subtle bug in withEncodedCString where a reference would be kept to the whole continuation until the continuation had finished executing. This was because the call to tryFillBufferAndCall could fail, if the buffer was already full and so the `go` helper would be recursively called on failure which necessitated keeping a reference to `act`. The failure could only happen during the initial checking phase of the function but not during the call to the continuation. Therefore the fix is to first perform the size check, potentially recursively and then finally calling tail calling the continuation. In the real world, this broke writing lazy bytestrings because a reference to the head of the bytestring would be retained in the continuation until the whole string had been written to a file. Fixes #20107
Diffstat (limited to 'libraries/base/tests/all.T')
-rw-r--r--libraries/base/tests/all.T1
1 files changed, 1 insertions, 0 deletions
diff --git a/libraries/base/tests/all.T b/libraries/base/tests/all.T
index 7ea69949e2..ebbf81ec52 100644
--- a/libraries/base/tests/all.T
+++ b/libraries/base/tests/all.T
@@ -264,3 +264,4 @@ test('clamp', normal, compile_and_run, [''])
test('T18642', extra_run_opts('+RTS -T -RTS'), compile_and_run, ['-O2'])
test('T19288', exit_code(1), compile_and_run, [''])
test('T19719', normal, compile_and_run, [''])
+test('T20107', extra_run_opts('+RTS -M50M'), compile_and_run, ['-package bytestring'])