decodeUtf8 invalid memory read
luc-tielen opened this issue · comments
Hi,
Today I stumbled upon a bug in the decodeUtf8
function of this package.
I ran the test suite for eclair-haskell under valgrind since I was searching for a memory corruption bug, and found this:
The bug ended up being fixed by the following diff, which uses fromPtr
from Data.Text.Foreign
: luc-tielen/eclair-haskell@7a2a039
The bug can be re-produced by cloning the repo, checking out the previous commit, building the code, and running the tests using valgrind (valgrind /path/to/test-executable
).
@luc-tielen "address ... is 1 bytes before" sounds similar to haskell/bytestring#620 (comment). Could you please try bytestring
HEAD? Does it fix the issue?
@Bodigrim Quick reply, nice! Looking at the C code that explains why I was seeing the rror. I was trying it on a string that was only 2 bytes long.
Just checked it after reverting my fix and bumping bytestring.. that seems to fix it!
Guess the real issue was me being behind on updating dependencies 😅.
Closing the issue.
@luc-tielen bytestring-0.11.5.3
has not been released yet, so unfortunately users are to be affected for quite some time, sorry for this.
@Bodigrim no worries, I have another fix that I posted before. Thanks for helping.