[libc-commits] [libc] 7aec387 - [libc][NFC] add an atof test for a fuzz failure

Michael Jones via libc-commits libc-commits at lists.llvm.org
Tue Mar 14 11:43:03 PDT 2023


Author: Michael Jones
Date: 2023-03-14T11:42:57-07:00
New Revision: 7aec387dbec77282482aaaac692158569e923966

URL: https://github.com/llvm/llvm-project/commit/7aec387dbec77282482aaaac692158569e923966
DIFF: https://github.com/llvm/llvm-project/commit/7aec387dbec77282482aaaac692158569e923966.diff

LOG: [libc][NFC] add an atof test for a fuzz failure

The differential fuzzer found that glibc and our libc disagree on the
result for "0x30000002222225p-1077", with ours being rounded up and
theirs rounded down. Ours is more correct for the nearest rounding mode,
so only a test is added.

Reviewed By: lntue, sivachandra

Differential Revision: https://reviews.llvm.org/D145821

Added: 
    

Modified: 
    libc/test/src/stdlib/strtod_test.cpp

Removed: 
    


################################################################################
diff  --git a/libc/test/src/stdlib/strtod_test.cpp b/libc/test/src/stdlib/strtod_test.cpp
index 3160ef3210c8..779c810f7208 100644
--- a/libc/test/src/stdlib/strtod_test.cpp
+++ b/libc/test/src/stdlib/strtod_test.cpp
@@ -191,4 +191,9 @@ TEST_F(LlvmLibcStrToDTest, FuzzFailures) {
            "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN?",
            0, uint64_t(0));
   run_test("0x.666E40", 9, uint64_t(0x3fd99b9000000000));
+
+  // glibc version 2.36 and higher (not tested with lower versions) disagrees
+  // with this result, but ours is correct for the nearest rounding mode. See
+  // this bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30220
+  run_test("0x30000002222225p-1077", 22, uint64_t(0x0006000000444445), ERANGE);
 }


        


More information about the libc-commits mailing list