From ced7256778699639d37cfa70ff65b4fcbdf62ebc Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 17 Mar 2021 17:37:59 -0700 Subject: [PATCH] [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 > > getFileAux(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, std::__1::allocator >*) (in /Users/chrisl/Projects/circt/build/bin Differential Revision: https://reviews.llvm.org/D98830 --- llvm/lib/Support/Unix/Process.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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());