]> git.kaiwu.me - njs.git/commitdiff
Improved test coverage with MemorySanitizer enabled.
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 29 Aug 2019 12:12:45 +0000 (15:12 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Thu, 29 Aug 2019 12:12:45 +0000 (15:12 +0300)
src/njs_clang.h
src/njs_random.c
src/test/njs_unit_test.c

index f3c306af0b77dcea0817f6023ed4dfb0170598c2..3a7c03da198d6a6215bbe4c1ca83e79b563deed5 100644 (file)
@@ -159,6 +159,9 @@ njs_leading_zeros64(uint64_t x)
 #include <sanitizer/msan_interface.h>
 
 #define njs_msan_unpoison(ptr, size)  __msan_unpoison(ptr, size)
+#else
+
+#define njs_msan_unpoison(ptr, size)
 #endif
 
 
index 0494f52e8db588e659d8cdef5e7320a5429fbcd2..b2fc674391fad23c1a5398d2a0a1c0f5c605f243 100644 (file)
@@ -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. */
index eafc7a8697ee079ba15e937ef1a99821a6b4f3be..c24bdc5e14afabb8744ea0e32cd1eea87f807774 100644 (file)
@@ -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") },