[compiler-rt] [llvm] [libFuzzer] Use uppercase "B" for byte units in output (PR #220828)

Stan Ulbrych via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 23:59:47 PDT 2026


https://github.com/StanFromIreland updated https://github.com/llvm/llvm-project/pull/220828

>From 439c407b68744afc281ba1738a92e00773404937 Mon Sep 17 00:00:00 2001
From: Stan Ulbrych <stan at python.org>
Date: Thu, 3 Sep 2026 07:53:12 +0100
Subject: [PATCH] [libFuzzer] Use uppercase "B" for byte units in output

Fixes issue #56766. libFuzzer printed data sizes as "b", "Kb" and "Mb", which denote bits. Use "B", "KB" and "MB" instead.
---
 compiler-rt/lib/fuzzer/FuzzerFlags.def        |  2 +-
 compiler-rt/lib/fuzzer/FuzzerLoop.cpp         | 14 +++++-----
 compiler-rt/lib/fuzzer/FuzzerMerge.cpp        |  2 +-
 compiler-rt/test/fuzzer/fuzzer-dirs.test      |  2 +-
 .../test/fuzzer/fuzzer-oom-with-profile.test  |  2 +-
 compiler-rt/test/fuzzer/fuzzer-oom.test       |  2 +-
 llvm/docs/LibFuzzer.md                        | 28 +++++++++----------
 7 files changed, 26 insertions(+), 26 deletions(-)

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 a93cd16b87934..510de1aa47399 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);
 }
 
@@ -816,8 +816,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 5037aaf8d9995..01d8069770d35 100644
--- a/llvm/docs/LibFuzzer.md
+++ b/llvm/docs/LibFuzzer.md
@@ -255,14 +255,14 @@ The most important command line options are:
 : Timeout in seconds, default 1200. If an input takes longer than this timeout,
   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.
   If running w/o ASAN/MSAN, you may use 'ulimit -v' instead.
 `-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) same limit as rss_limit_mb is applied.
 `-timeout_exitcode`
 : Exit code (default 77) used if libFuzzer reports a timeout.
@@ -344,12 +344,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-
 ...
 ```
 
@@ -445,12 +445,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