[llvm] ced7256 - [libsupport] Silence a bogus valgrind warning.

Chris Lattner via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 18 09:09:49 PDT 2021


Author: Chris Lattner
Date: 2021-03-18T09:09:20-07:00
New Revision: ced7256778699639d37cfa70ff65b4fcbdf62ebc

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

LOG: [libsupport] Silence a bogus valgrind warning.

Valgrind is reporting this bogus warning because it doesn't model
pthread_sigmask fully accurately.  This is a valgrind bug, but
silencing it has effectively no cost, so just do it.

==73662== Syscall param __pthread_sigmask(set) points to uninitialised byte(s)
==73662==    at 0x101E9D4C2: __pthread_sigmask (in /usr/lib/system/libsystem_kernel.dylib)
==73662==    by 0x101EFB5EA: pthread_sigmask (in /usr/lib/system/libsystem_pthread.dylib)
==73662==    by 0x1000D9F6D: llvm::sys::Process::SafelyCloseFileDescriptor(int) (in /Users/chrisl/Projects/circt/build/bin/firtool)
==73662==    by 0x100072795: llvm::ErrorOr<std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> > > getFileAux<llvm::MemoryBuffer>(llvm::Twine const&, long long, unsigned long long, unsigned long long, bool, bool) (in /Users/chrisl/Projects/circt/build/bin/firtool)
==73662==    by 0x100072573: llvm::MemoryBuffer::getFileOrSTDIN(llvm::Twine const&, long long, bool) (in /Users/chrisl/Projects/circt/build/bin/firtool)
==73662==    by 0x100282C25: mlir::openInputFile(llvm::StringRef, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*) (in /Users/chrisl/Projects/circt/build/bin

Differential Revision: https://reviews.llvm.org/D98830

Added: 
    

Modified: 
    llvm/lib/Support/Unix/Process.inc

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc
index c3d8f7001de3..1ea36aae63f2 100644
--- a/llvm/lib/Support/Unix/Process.inc
+++ b/llvm/lib/Support/Unix/Process.inc
@@ -236,11 +236,11 @@ std::error_code Process::FixupStandardFileDescriptors() {
 
 std::error_code Process::SafelyCloseFileDescriptor(int FD) {
   // Create a signal set filled with *all* signals.
-  sigset_t FullSet;
-  if (sigfillset(&FullSet) < 0)
+  sigset_t FullSet, SavedSet;
+  if (sigfillset(&FullSet) < 0 || sigfillset(&SavedSet) < 0)
     return std::error_code(errno, std::generic_category());
+
   // Atomically swap our current signal mask with a full mask.
-  sigset_t SavedSet;
 #if LLVM_ENABLE_THREADS
   if (int EC = pthread_sigmask(SIG_SETMASK, &FullSet, &SavedSet))
     return std::error_code(EC, std::generic_category());


        


More information about the llvm-commits mailing list