diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-15 07:24:13 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-15 07:24:13 -0700 |
commit | d14f512d7ad71f2cb3bd927f69dfc742514a79a2 (patch) | |
tree | 16cba4cb5d59017161439b3788549ce224e44bc8 /signal.c | |
parent | e48c8fc606ce545fd0b241e55dd4f64624598ac5 (diff) | |
download | txr-d14f512d7ad71f2cb3bd927f69dfc742514a79a2.tar.gz txr-d14f512d7ad71f2cb3bd927f69dfc742514a79a2.tar.bz2 txr-d14f512d7ad71f2cb3bd927f69dfc742514a79a2.zip |
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.
Diffstat (limited to 'signal.c')
-rw-r--r-- | signal.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -37,6 +37,9 @@ #if HAVE_SYS_TIME #include <sys/time.h> #endif +#if HAVE_VALGRIND +#include <valgrind/memcheck.h> +#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); } |