dtoa-benchmark icon indicating copy to clipboard operation
dtoa-benchmark copied to clipboard

milo: some numbers cause overflow in DigitGen

Open rdb opened this issue 9 years ago • 2 comments

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.

rdb avatar May 26 '16 00:05 rdb

Thank you. I will check about it.

miloyip avatar May 26 '16 05:05 miloyip

This was fixed in https://github.com/miloyip/rapidjson/commit/fe550f38669fe0f488926c1ef0feb6c101f586d6.

dtolnay avatar Jul 20 '16 18:07 dtolnay