[PATCH] D57531: [fuzzer] Use RawPrint instead of Printf for instrumentation warning

Jonathan Metzman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 31 12:32:13 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT352789: [fuzzer] Use RawPrint instead of Printf for instrumentation warning (authored by metzman, committed by ).
Herald added subscribers: Sanitizers, llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57531?vs=184573&id=184574#toc

Repository:
  rCRT Compiler Runtime

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57531/new/

https://reviews.llvm.org/D57531

Files:
  lib/fuzzer/FuzzerIOWindows.cpp
  lib/fuzzer/FuzzerTracePC.cpp
  test/fuzzer/deprecated-instrumentation.test


Index: test/fuzzer/deprecated-instrumentation.test
===================================================================
--- test/fuzzer/deprecated-instrumentation.test
+++ test/fuzzer/deprecated-instrumentation.test
@@ -1,4 +1,4 @@
-CHECK: libFuzzer does not support -fsanitize-coverage=trace-pc
+CHECK: -fsanitize-coverage=trace-pc is no longer supported by libFuzzer
 RUN: %cpp_compiler %S/SimpleTest.cpp -c -o %t-SimpleTest.o -fsanitize-coverage=trace-pc
 RUN: %cpp_compiler %t-SimpleTest.o -o %t-SimpleTest
 RUN: not %run %t-SimpleTest 2>&1 | FileCheck %s
Index: lib/fuzzer/FuzzerIOWindows.cpp
===================================================================
--- lib/fuzzer/FuzzerIOWindows.cpp
+++ lib/fuzzer/FuzzerIOWindows.cpp
@@ -334,7 +334,7 @@
 
 void RawPrint(const char *Str) {
   // Not tested, may or may not work. Fix if needed.
-  Printf("%s", Str);
+  write(2, Str, strlen(Str));
 }
 
 }  // namespace fuzzer
Index: lib/fuzzer/FuzzerTracePC.cpp
===================================================================
--- lib/fuzzer/FuzzerTracePC.cpp
+++ lib/fuzzer/FuzzerTracePC.cpp
@@ -403,9 +403,13 @@
 }
 
 void WarnAboutDeprecatedInstrumentation(const char *flag) {
-  Printf("libFuzzer does not support %s any more.\n"
-         "Please either migrate to a compiler that supports -fsanitize=fuzzer\n"
-         "or use an older version of libFuzzer\n", flag);
+  // Use RawPrint because Printf cannot be used on Windows before OutputFile is
+  // initialized.
+  RawPrint(flag);
+  RawPrint(
+      " is no longer supported by libFuzzer.\n"
+      "Please either migrate to a compiler that supports -fsanitize=fuzzer\n"
+      "or use an older version of libFuzzer\n");
   exit(1);
 }
 
@@ -415,7 +419,8 @@
 ATTRIBUTE_INTERFACE
 ATTRIBUTE_NO_SANITIZE_ALL
 void __sanitizer_cov_trace_pc_guard(uint32_t *Guard) {
-  fuzzer::WarnAboutDeprecatedInstrumentation("-fsanitize-coverage=trace-pc");
+  fuzzer::WarnAboutDeprecatedInstrumentation(
+      "-fsanitize-coverage=trace-pc-guard");
 }
 
 // Best-effort support for -fsanitize-coverage=trace-pc, which is available
@@ -423,8 +428,7 @@
 ATTRIBUTE_INTERFACE
 ATTRIBUTE_NO_SANITIZE_ALL
 void __sanitizer_cov_trace_pc() {
-  fuzzer::WarnAboutDeprecatedInstrumentation(
-      "-fsanitize-coverage=trace-pc-guard");
+  fuzzer::WarnAboutDeprecatedInstrumentation("-fsanitize-coverage=trace-pc");
 }
 
 ATTRIBUTE_INTERFACE


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57531.184574.patch
Type: text/x-patch
Size: 2385 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190131/fa77325b/attachment.bin>


More information about the llvm-commits mailing list