[llvm] r271465 - [libFuzzer] use __sanitizer_print_memory_profile to print the memory profile on OOM

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 18:33:12 PDT 2016


Author: kcc
Date: Wed Jun  1 20:33:11 2016
New Revision: 271465

URL: http://llvm.org/viewvc/llvm-project?rev=271465&view=rev
Log:
[libFuzzer] use __sanitizer_print_memory_profile to print the memory profile on OOM

Modified:
    llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
    llvm/trunk/lib/Fuzzer/test/fuzzer-oom.test

Modified: llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp?rev=271465&r1=271464&r2=271465&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp (original)
+++ llvm/trunk/lib/Fuzzer/FuzzerLoop.cpp Wed Jun  1 20:33:11 2016
@@ -55,6 +55,7 @@ __attribute__((weak)) void __sanitizer_f
 __attribute__((weak)) void __lsan_enable();
 __attribute__((weak)) void __lsan_disable();
 __attribute__((weak)) int __lsan_do_recoverable_leak_check();
+__attribute__((weak)) int __sanitizer_print_memory_profile(size_t);
 }
 
 namespace fuzzer {
@@ -256,7 +257,9 @@ void Fuzzer::RssLimitCallback() {
   Printf(
       "==%d== ERROR: libFuzzer: out-of-memory (used: %zdMb; limit: %zdMb)\n",
       GetPid(), GetPeakRSSMb(), Options.RssLimitMb);
-  Printf("   To change the out-of-memory limit use -rss_limit_mb=<N>\n");
+  Printf("   To change the out-of-memory limit use -rss_limit_mb=<N>\n\n");
+  if (__sanitizer_print_memory_profile)
+    __sanitizer_print_memory_profile(50);
   DumpCurrentUnit("oom-");
   Printf("SUMMARY: libFuzzer: out-of-memory\n");
   PrintFinalStats();

Modified: llvm/trunk/lib/Fuzzer/test/fuzzer-oom.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/fuzzer-oom.test?rev=271465&r1=271464&r2=271465&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/fuzzer-oom.test (original)
+++ llvm/trunk/lib/Fuzzer/test/fuzzer-oom.test Wed Jun  1 20:33:11 2016
@@ -1,4 +1,5 @@
 RUN: not LLVMFuzzer-OutOfMemoryTest -rss_limit_mb=10 2>&1 | FileCheck %s
 CHECK: ERROR: libFuzzer: out-of-memory (used: {{.*}}; limit: 10Mb)
+CHECK: Live Heap Allocations
 CHECK: Test unit written to ./oom-
 SUMMARY: libFuzzer: out-of-memory




More information about the llvm-commits mailing list