[llvm] 20ddf3e - [libFuzzer] Use uppercase "B" for byte units in output (#220828)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 09:49:00 PDT 2026


Author: Stan Ulbrych
Date: 2026-09-10T09:48:56-07:00
New Revision: 20ddf3e2f5a9fa2717d9cfea19660ef1f0399044

URL: https://github.com/llvm/llvm-project/commit/20ddf3e2f5a9fa2717d9cfea19660ef1f0399044
DIFF: https://github.com/llvm/llvm-project/commit/20ddf3e2f5a9fa2717d9cfea19660ef1f0399044.diff

LOG: [libFuzzer] Use uppercase "B" for byte units in output (#220828)

Fixes issue #56766. libFuzzer printed data sizes as "b", "Kb" and "Mb",
which denote bits. Use "B", "KB" and "MB" instead.

Added: 
    

Modified: 
    compiler-rt/lib/fuzzer/FuzzerFlags.def
    compiler-rt/lib/fuzzer/FuzzerLoop.cpp
    compiler-rt/lib/fuzzer/FuzzerMerge.cpp
    compiler-rt/test/fuzzer/fuzzer-dirs.test
    compiler-rt/test/fuzzer/fuzzer-oom-with-profile.test
    compiler-rt/test/fuzzer/fuzzer-oom.test
    llvm/docs/LibFuzzer.md

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/fuzzer/FuzzerFlags.def b/compiler-rt/lib/fuzzer/FuzzerFlags.def
index 96282b8f72a4f..d0c6d5fd97a2c 100644
--- a/compiler-rt/lib/fuzzer/FuzzerFlags.def
+++ b/compiler-rt/lib/fuzzer/FuzzerFlags.def
@@ -172,7 +172,7 @@ FUZZER_FLAG_INT(trace_malloc, 0, "If >= 1 will print all mallocs/frees. "
 FUZZER_FLAG_INT(rss_limit_mb, 2048, "If non-zero, the fuzzer will exit upon "
     "reaching this limit of RSS memory usage.")
 FUZZER_FLAG_INT(malloc_limit_mb, 0, "If non-zero, the fuzzer will exit "
-    "if the target tries to allocate this number of Mb with one malloc call. "
+    "if the target tries to allocate this number of MB with one malloc call. "
     "If zero (default) same limit as rss_limit_mb is applied.")
 FUZZER_FLAG_STRING(exit_on_src_pos, "Exit if a newly found PC originates"
     " from the given source location. Example: -exit_on_src_pos=foo.cc:123. "

diff  --git a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
index 084f91de199d2..39ccf50c40069 100644
--- a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
@@ -312,7 +312,7 @@ void Fuzzer::RssLimitCallback() {
   if (EF->__sanitizer_acquire_crash_state &&
       !EF->__sanitizer_acquire_crash_state())
     return;
-  Printf("==%lu== ERROR: libFuzzer: out-of-memory (used: %zdMb; limit: %dMb)\n",
+  Printf("==%lu== ERROR: libFuzzer: out-of-memory (used: %zdMB; limit: %dMB)\n",
          GetPid(), GetPeakRSSMb(), Options.RssLimitMb);
   Printf("   To change the out-of-memory limit use -rss_limit_mb=<N>\n\n");
   PrintMemoryProfile();
@@ -336,11 +336,11 @@ void Fuzzer::PrintStats(const char *Where, const char *End, size_t Units,
     Printf(" corp: %zd", Corpus.NumActiveUnits());
     if (size_t N = Corpus.SizeInBytes()) {
       if (N < (1 << 14))
-        Printf("/%zdb", N);
+        Printf("/%zdB", N);
       else if (N < (1 << 24))
-        Printf("/%zdKb", N >> 10);
+        Printf("/%zdKB", N >> 10);
       else
-        Printf("/%zdMb", N >> 20);
+        Printf("/%zdMB", N >> 20);
     }
     if (size_t FF = Corpus.NumInputsThatTouchFocusFunction())
       Printf(" focus: %zd", FF);
@@ -351,7 +351,7 @@ void Fuzzer::PrintStats(const char *Where, const char *End, size_t Units,
     Printf(" units: %zd", Units);
 
   Printf(" exec/s: %zd", ExecPerSec);
-  Printf(" rss: %zdMb", GetPeakRSSMb());
+  Printf(" rss: %zdMB", GetPeakRSSMb());
   Printf("%s", End);
 }
 
@@ -817,8 +817,8 @@ void Fuzzer::ReadAndExecuteSeedCorpora(std::vector<SizedFile> &CorporaFiles) {
     Unit U({'\n'}); // Valid ASCII input.
     RunOne(U.data(), U.size());
   } else {
-    Printf("INFO: seed corpus: files: %zd min: %zdb max: %zdb total: %zdb"
-           " rss: %zdMb\n",
+    Printf("INFO: seed corpus: files: %zd min: %zdB max: %zdB total: %zdB"
+           " rss: %zdMB\n",
            CorporaFiles.size(), MinSize, MaxSize, TotalSize, GetPeakRSSMb());
     if (Options.ShuffleAtStartUp)
       std::shuffle(CorporaFiles.begin(), CorporaFiles.end(), MD.GetRand());

diff  --git a/compiler-rt/lib/fuzzer/FuzzerMerge.cpp b/compiler-rt/lib/fuzzer/FuzzerMerge.cpp
index 8c8806e8aafd3..a974a56c1b7e7 100644
--- a/compiler-rt/lib/fuzzer/FuzzerMerge.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerMerge.cpp
@@ -523,7 +523,7 @@ void CrashResistantMerge(const std::vector<std::string> &Args,
   M.ParseOrExit(IF, true);
   IF.close();
   VPrintf(V,
-          "MERGE-OUTER: consumed %zdMb (%zdMb rss) to parse the control file\n",
+          "MERGE-OUTER: consumed %zdMB (%zdMB rss) to parse the control file\n",
           M.ApproximateMemoryConsumption() >> 20, GetPeakRSSMb());
 
   M.Files.insert(M.Files.end(), KnownFiles.begin(), KnownFiles.end());

diff  --git a/compiler-rt/test/fuzzer/fuzzer-dirs.test b/compiler-rt/test/fuzzer/fuzzer-dirs.test
index c822c2f95c305..ab4ab5a874eb4 100644
--- a/compiler-rt/test/fuzzer/fuzzer-dirs.test
+++ b/compiler-rt/test/fuzzer/fuzzer-dirs.test
@@ -6,7 +6,7 @@ RUN: echo a > %t/SUB1/a
 RUN: echo b > %t/SUB1/SUB2/b
 RUN: echo c > %t/SUB1/SUB2/SUB3/c
 RUN: %run %t-SimpleTest %t/SUB1 -runs=0 2>&1 | FileCheck %s --check-prefix=SUBDIRS
-SUBDIRS: INFO: seed corpus: files: 3 min: 2b max: 2b total: 6b
+SUBDIRS: INFO: seed corpus: files: 3 min: 2B max: 2B total: 6B
 RUN: echo -n zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz > %t/SUB1/f64
 RUN: cat %t/SUB1/f64 %t/SUB1/f64 %t/SUB1/f64 %t/SUB1/f64 > %t/SUB1/f256
 RUN: cat %t/SUB1/f256 %t/SUB1/f256 %t/SUB1/f256 %t/SUB1/f256 > %t/SUB1/f1024

diff  --git a/compiler-rt/test/fuzzer/fuzzer-oom-with-profile.test b/compiler-rt/test/fuzzer/fuzzer-oom-with-profile.test
index 918197abd5a24..ef9f62b0e1be4 100644
--- a/compiler-rt/test/fuzzer/fuzzer-oom-with-profile.test
+++ b/compiler-rt/test/fuzzer/fuzzer-oom-with-profile.test
@@ -1,7 +1,7 @@
 REQUIRES: linux
 RUN: %cpp_compiler %S/OutOfMemoryTest.cpp -o %t-OutOfMemoryTest
 RUN: not %run %t-OutOfMemoryTest -rss_limit_mb=300 2>&1 | FileCheck %s
-CHECK: ERROR: libFuzzer: out-of-memory (used: {{.*}}; limit: 300Mb)
+CHECK: ERROR: libFuzzer: out-of-memory (used: {{.*}}; limit: 300MB)
 CHECK: Live Heap Allocations
 CHECK: Test unit written to ./oom-
 SUMMARY: libFuzzer: out-of-memory

diff  --git a/compiler-rt/test/fuzzer/fuzzer-oom.test b/compiler-rt/test/fuzzer/fuzzer-oom.test
index ca6ca73121870..e06e455884ba7 100644
--- a/compiler-rt/test/fuzzer/fuzzer-oom.test
+++ b/compiler-rt/test/fuzzer/fuzzer-oom.test
@@ -9,7 +9,7 @@ RUN: %cpp_compiler %S/AccumulateAllocationsTest.cpp -o %t-AccumulateAllocationsT
 
 RUN: not %run %t-OutOfMemoryTest.exe -rss_limit_mb=300 2>&1 | FileCheck %s
 
-CHECK: ERROR: libFuzzer: out-of-memory (used: {{.*}}; limit: 300Mb)
+CHECK: ERROR: libFuzzer: out-of-memory (used: {{.*}}; limit: 300MB)
 CHECK: Test unit written to ./oom-
 SUMMARY: libFuzzer: out-of-memory
 

diff  --git a/llvm/docs/LibFuzzer.md b/llvm/docs/LibFuzzer.md
index 3d16c2afd6218..cb2575e4b5514 100644
--- a/llvm/docs/LibFuzzer.md
+++ b/llvm/docs/LibFuzzer.md
@@ -263,7 +263,7 @@ The most important command line options are:
   the process is treated as a failure case.
 
 `-rss_limit_mb`
-: Memory usage limit in Mb, default 2048. Use 0 to disable the limit.
+: Memory usage limit in MB, default 2048. Use 0 to disable the limit.
   If an input requires more than this amount of RSS memory to execute,
   the process is treated as a failure case.
   The limit is checked in a separate thread every second.
@@ -271,7 +271,7 @@ The most important command line options are:
 
 `-malloc_limit_mb`
 : If non-zero, the fuzzer will exit if the target tries to allocate this
-  number of Mb with one malloc call.
+  number of MB with one malloc call.
   If zero (default) the same limit as rss_limit_mb is applied.
 
 `-timeout_exitcode`
@@ -375,12 +375,12 @@ INFO: Loaded 1 modules   (8 inline 8-bit counters): 8 [0x5f03d189be90, 0x5f03d18
 INFO: Loaded 1 PC tables (8 PCs): 8 [0x5f03d189be98,0x5f03d189bf18),
 INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
 INFO: A corpus is not provided, starting from an empty corpus
-#2      INITED cov: 2 ft: 2 corp: 1/1b exec/s: 0 rss: 31Mb
-#144    NEW    cov: 3 ft: 3 corp: 2/2b lim: 4 exec/s: 0 rss: 31Mb L: 1/1 MS: 2 ChangeByte-ChangeByte-
-#157    NEW    cov: 4 ft: 4 corp: 3/4b lim: 4 exec/s: 0 rss: 31Mb L: 2/2 MS: 3 CrossOver-ChangeBit-CrossOver-
-#1345   NEW    cov: 5 ft: 5 corp: 4/8b lim: 14 exec/s: 0 rss: 32Mb L: 4/4 MS: 3 InsertByte-ChangeBit-CrossOver-
-#1696   NEW    cov: 6 ft: 6 corp: 5/10b lim: 17 exec/s: 0 rss: 32Mb L: 2/4 MS: 1 EraseBytes-
-#1832   REDUCE cov: 6 ft: 6 corp: 5/9b lim: 17 exec/s: 0 rss: 32Mb L: 3/3 MS: 1 EraseBytes-
+#2      INITED cov: 2 ft: 2 corp: 1/1B exec/s: 0 rss: 31MB
+#144    NEW    cov: 3 ft: 3 corp: 2/2B lim: 4 exec/s: 0 rss: 31MB L: 1/1 MS: 2 ChangeByte-ChangeByte-
+#157    NEW    cov: 4 ft: 4 corp: 3/4B lim: 4 exec/s: 0 rss: 31MB L: 2/2 MS: 3 CrossOver-ChangeBit-CrossOver-
+#1345   NEW    cov: 5 ft: 5 corp: 4/8B lim: 14 exec/s: 0 rss: 32MB L: 4/4 MS: 3 InsertByte-ChangeBit-CrossOver-
+#1696   NEW    cov: 6 ft: 6 corp: 5/10B lim: 17 exec/s: 0 rss: 32MB L: 2/4 MS: 1 EraseBytes-
+#1832   REDUCE cov: 6 ft: 6 corp: 5/9B lim: 17 exec/s: 0 rss: 32MB L: 3/3 MS: 1 EraseBytes-
 ...
 ```
 
@@ -488,12 +488,12 @@ INFO: Loaded 1 modules   (8 inline 8-bit counters): 8 [0x5f03d189be90, 0x5f03d18
 INFO: Loaded 1 PC tables (8 PCs): 8 [0x5f03d189be98,0x5f03d189bf18),
 INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
 INFO: A corpus is not provided, starting from an empty corpus
-#2      INITED cov: 2 ft: 2 corp: 1/1b exec/s: 0 rss: 31Mb
-#144    NEW    cov: 3 ft: 3 corp: 2/2b lim: 4 exec/s: 0 rss: 31Mb L: 1/1 MS: 2 ChangeByte-ChangeByte-
-#157    NEW    cov: 4 ft: 4 corp: 3/4b lim: 4 exec/s: 0 rss: 31Mb L: 2/2 MS: 3 CrossOver-ChangeBit-CrossOver-
-#1345   NEW    cov: 5 ft: 5 corp: 4/8b lim: 14 exec/s: 0 rss: 32Mb L: 4/4 MS: 3 InsertByte-ChangeBit-CrossOver-
-#1696   NEW    cov: 6 ft: 6 corp: 5/10b lim: 17 exec/s: 0 rss: 32Mb L: 2/4 MS: 1 EraseBytes-
-#1832   REDUCE cov: 6 ft: 6 corp: 5/9b lim: 17 exec/s: 0 rss: 32Mb L: 3/3 MS: 1 EraseBytes-
+#2      INITED cov: 2 ft: 2 corp: 1/1B exec/s: 0 rss: 31MB
+#144    NEW    cov: 3 ft: 3 corp: 2/2B lim: 4 exec/s: 0 rss: 31MB L: 1/1 MS: 2 ChangeByte-ChangeByte-
+#157    NEW    cov: 4 ft: 4 corp: 3/4B lim: 4 exec/s: 0 rss: 31MB L: 2/2 MS: 3 CrossOver-ChangeBit-CrossOver-
+#1345   NEW    cov: 5 ft: 5 corp: 4/8B lim: 14 exec/s: 0 rss: 32MB L: 4/4 MS: 3 InsertByte-ChangeBit-CrossOver-
+#1696   NEW    cov: 6 ft: 6 corp: 5/10B lim: 17 exec/s: 0 rss: 32MB L: 2/4 MS: 1 EraseBytes-
+#1832   REDUCE cov: 6 ft: 6 corp: 5/9B lim: 17 exec/s: 0 rss: 32MB L: 3/3 MS: 1 EraseBytes-
 ==840148== ERROR: libFuzzer: deadly signal
 ...
 SUMMARY: libFuzzer: deadly signal


        


More information about the llvm-commits mailing list