-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combining hPutBuilder + primMapByteStringBounded unsafe with reuse? #203
Comments
I found the problem, it is an off-by-one error, causing an infinite loop between the builder and BufferFull, when the available space is exactly equal to diff --git a/Data/ByteString/Builder/Prim.hs b/Data/ByteString/Builder/Prim.hs
index 777b309..4dcc150 100644
--- a/Data/ByteString/Builder/Prim.hs
+++ b/Data/ByteString/Builder/Prim.hs
@@ -652,7 +652,7 @@ primMapByteStringBounded w =
touchForeignPtr ifp -- input buffer consumed
k br
- | op0 `plusPtr` bound < ope =
+ | op0 `plusPtr` bound <= ope =
goPartial (ip0 `plusPtr` min outRemaining inpRemaining)
| otherwise = return $ bufferFull bound op0 (goBS ip0) |
Oh, that's a know bug! See #117 (comment). I hadn't known how it would manifest though! A PR just for the bug fix would be much appreciated! |
Here's the PR: #204 |
Wow, previously found and patched elsewhere almost three years ago! :-( I hope the fix makes it in this time... |
Fixed with #204 |
The program below will hang if the iteration count (command-line argument) is sufficiently high, 253 loops or more (the default of 10 shows it working initially):
The text was updated successfully, but these errors were encountered: