[compiler-rt] [libfuzzer] Prevent MSan false positive when printing log with -jobs (PR #91679)

Thurston Dang via llvm-commits llvm-commits at lists.llvm.org
Thu May 9 16:43:47 PDT 2024


https://github.com/thurstond created https://github.com/llvm/llvm-project/pull/91679

The -jobs option will, depending on the number of CPUs, spin up a
WorkerThread and end up printing the log file using CopyFileToErr.
This leads to an MSan false positive. This patch disables the MSan interceptor checks,
similarly to other instances in https://reviews.llvm.org/D48891

Side-note: this false positive issue first appeared when printf()
was replaced by puts() (90b4d1bcb20180c591385131b12fa90d2e4860b1).
The interceptor check was always present; however, MSan does not
check_printf by default.


>From 3b448ad0707cb95ebdf74d331b9e17d2ed866bb7 Mon Sep 17 00:00:00 2001
From: Thurston Dang <thurston at google.com>
Date: Thu, 9 May 2024 23:37:41 +0000
Subject: [PATCH] [libfuzzer] Prevent MSan false positive when printing log
 with -jobs

The -jobs option will, depending on the number of CPUs, spin up a
WorkerThread and end up printing the log file using CopyFileToErr.
This leads to an MSan false positive. This patch disables the MSan interceptor checks,
similarly to other instances in https://reviews.llvm.org/D48891

Side-note: this false positive issue first appeared when printf()
was replaced by puts() (90b4d1bcb20180c591385131b12fa90d2e4860b1).
The interceptor check was always present; however, MSan does not
check_printf by default.
---
 compiler-rt/lib/fuzzer/FuzzerIO.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/compiler-rt/lib/fuzzer/FuzzerIO.cpp b/compiler-rt/lib/fuzzer/FuzzerIO.cpp
index 54cc4ee54be0a..9e9a93a0a48da 100644
--- a/compiler-rt/lib/fuzzer/FuzzerIO.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerIO.cpp
@@ -10,6 +10,7 @@
 
 #include "FuzzerDefs.h"
 #include "FuzzerExtFunctions.h"
+#include "FuzzerInternal.h"
 #include "FuzzerIO.h"
 #include "FuzzerUtil.h"
 #include <algorithm>
@@ -65,6 +66,7 @@ std::string FileToString(const std::string &Path) {
 }
 
 void CopyFileToErr(const std::string &Path) {
+  ScopedDisableMsanInterceptorChecks S;
   Puts(FileToString(Path).c_str());
 }
 



More information about the llvm-commits mailing list