From 29be339dfab39b2c07d49a76d9f666e88a9d313e Mon Sep 17 00:00:00 2001 From: Dmitry Volyntsev Date: Thu, 29 Aug 2019 15:12:45 +0300 Subject: [PATCH] Improved test coverage with MemorySanitizer enabled. --- src/njs_clang.h | 3 +++ src/njs_random.c | 2 ++ src/test/njs_unit_test.c | 2 -- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/njs_clang.h b/src/njs_clang.h index f3c306af..3a7c03da 100644 --- a/src/njs_clang.h +++ b/src/njs_clang.h @@ -159,6 +159,9 @@ njs_leading_zeros64(uint64_t x) #include #define njs_msan_unpoison(ptr, size) __msan_unpoison(ptr, size) +#else + +#define njs_msan_unpoison(ptr, size) #endif diff --git a/src/njs_random.c b/src/njs_random.c index 0494f52e..b2fc6743 100644 --- a/src/njs_random.c +++ b/src/njs_random.c @@ -105,6 +105,8 @@ njs_random_stir(njs_random_t *r, njs_pid_t pid) key.value[2] ^= getpid(); } + njs_msan_unpoison(&key, NJS_RANDOM_KEY_SIZE); + njs_random_add(r, key.bytes, NJS_RANDOM_KEY_SIZE); /* Drop the first 3072 bytes. */ diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c index eafc7a86..c24bdc5e 100644 --- a/src/test/njs_unit_test.c +++ b/src/test/njs_unit_test.c @@ -12165,10 +12165,8 @@ static njs_unit_test_t njs_test[] = { njs_str("Math.pow(-3, 0.1)"), njs_str("NaN") }, -#if (!NJS_HAVE_MEMORY_SANITIZER) /* intentional use of uninitialized stack */ { njs_str("var a = Math.random(); a >= 0 && a < 1"), njs_str("true") }, -#endif { njs_str("Math.round()"), njs_str("NaN") }, -- 2.47.3