Skip to content
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

milo: some numbers cause overflow in DigitGen #7

Open
rdb opened this issue May 26, 2016 · 2 comments
Open

milo: some numbers cause overflow in DigitGen #7

rdb opened this issue May 26, 2016 · 2 comments

Comments

@rdb
Copy link

rdb commented May 26, 2016

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.

@miloyip
Copy link
Owner

miloyip commented May 26, 2016

Thank you. I will check about it.

@dtolnay
Copy link

dtolnay commented Jul 20, 2016

This was fixed in Tencent/rapidjson@fe550f3.

e-n-f added a commit to mapbox/tile-count that referenced this issue Nov 2, 2017
miloyip/dtoa-benchmark#7

commit fe550f38669fe0f488926c1ef0feb6c101f586d6
Author: Eli Fidler <[email protected]>
Date:   Tue May 31 11:51:37 2016 -0400

    avoid array index out-of-bounds

    UBSAN gave "runtime error: index 13 out of bounds for type 'const uint32_t [10]'"
e-n-f added a commit to mapbox/tippecanoe that referenced this issue Nov 2, 2017
miloyip/dtoa-benchmark#7

commit fe550f38669fe0f488926c1ef0feb6c101f586d6
Author: Eli Fidler <[email protected]>
Date:   Tue May 31 11:51:37 2016 -0400

    avoid array index out-of-bounds

    UBSAN gave "runtime error: index 13 out of bounds for type 'const uint32_t [10]'"
e-n-f added a commit to mapbox/tippecanoe that referenced this issue Nov 2, 2017
miloyip/dtoa-benchmark#7

commit fe550f38669fe0f488926c1ef0feb6c101f586d6
Author: Eli Fidler <[email protected]>
Date:   Tue May 31 11:51:37 2016 -0400

    avoid array index out-of-bounds

    UBSAN gave "runtime error: index 13 out of bounds for type 'const uint32_t [10]'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants