From d14f512d7ad71f2cb3bd927f69dfc742514a79a2 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 15 Sep 2015 07:24:13 -0700 Subject: False positive valgrind error: uninitialized sigset_t. The issue is that sigset_t is 1024 bits wide on Linux, but there aren't actually that many signals. Valgrind knows this and so when sigprocmask returns the old signal set, Valgrind only marks a portion of it as initialized, and not the entire 1024 bits. When this sigset_t is later passed into sig_set again, we do a memcmp on all 1024 bits and Valgrind complains about a use of uninitialized data. Test case: run valgrind ./txr -i and execute a (throw 'foo) expr. * signal.c (sig_mask): If we are compiling with Valgrind support, mark the old signal set defined just before passing it to sigprocmask, so it has no uninitialized bits. --- signal.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/signal.c b/signal.c index b5f8f464..05554a64 100644 --- a/signal.c +++ b/signal.c @@ -37,6 +37,9 @@ #if HAVE_SYS_TIME #include #endif +#if HAVE_VALGRIND +#include +#endif #include "lib.h" #include "gc.h" #include "signal.h" @@ -366,6 +369,9 @@ int sig_mask(int how, const sigset_t *set, sigset_t *oldset) if (memcmp(&sig_blocked_cache, pnew, sizeof *pnew) != 0) { sig_blocked_cache = *pnew; +#if HAVE_VALGRIND + VALGRIND_MAKE_MEM_DEFINED(oldset, sizeof *oldset); +#endif return sigprocmask(SIG_SETMASK, &sig_blocked_cache, oldset); } -- cgit v1.2.3