This is an archive of the discontinued LLVM Phabricator instance.

[libc] Fix printf %e and %g bugs
ClosedPublic

Authored by michaelrj on Aug 9 2023, 11:43 AM.

Details

Summary

Fuzzing revealed bugs in the %e and %g conversions. Since these are very
similar, they are grouped together. Again, most of the bugs were related
to rounding. As an example, previously the code to check if the number
was truncated only worked for digits below the decimal point, due to it
being originally designed for %f. This patch adds a mechanism to check
the digits above the decimal point for both %e and %g.

Diff Detail

Event Timeline

michaelrj created this revision.Aug 9 2023, 11:43 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 9 2023, 11:43 AM
michaelrj requested review of this revision.Aug 9 2023, 11:43 AM
michaelrj updated this revision to Diff 548801.Aug 9 2023, 3:54 PM

add explanatory comments

lntue accepted this revision.Aug 10 2023, 7:45 AM
This revision is now accepted and ready to land.Aug 10 2023, 7:45 AM
sivachandra accepted this revision.Aug 11 2023, 1:35 PM
sivachandra added inline comments.
libc/test/src/stdio/sprintf_test.cpp
2563–2575

If categories are important, you choose to leave this note but find a better category name. "Base 10 rounding tests" ?

michaelrj updated this revision to Diff 549532.Aug 11 2023, 3:01 PM
michaelrj marked an inline comment as done.

adjust test comments

libc/test/src/stdio/sprintf_test.cpp
2563–2575

These are already in the "Precision Tests" category, which is focused on testing the precision mechanism that also covers rounding.

This revision was landed with ongoing or failed builds.Aug 15 2023, 4:23 PM
This revision was automatically updated to reflect the committed changes.