dtoa-benchmark
dtoa-benchmark copied to clipboard
milo: some numbers cause overflow in DigitGen
Clang's address sanitizer traps on the milo algorithm when using this number:
0.020000000000000005 (hex 0x3f947ae147ae147c)
In the DigitGen function, it tries to access the kPow10 array with an overflowing index. This is the offending line:
GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * kPow10[-kappa]);
The kappa value in question is -14 when it traps. Padding the kPow10 with five extra zeroes at the end seems to work around the issue, but I don't understand the code well enough to comment on whether that is a good solution.
Thank you. I will check about it.
This was fixed in https://github.com/miloyip/rapidjson/commit/fe550f38669fe0f488926c1ef0feb6c101f586d6.