[njs] Added detection of address sanitizer.

Dmitry Volyntsev xeioex at nginx.com
Tue Aug 13 13:14:11 UTC 2019


details:   https://hg.nginx.org/njs/rev/ab443df0d924
branches:  
changeset: 1126:ab443df0d924
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Tue Aug 13 16:04:10 2019 +0300
description:
Added detection of address sanitizer.

diffstat:

 auto/clang               |  20 ++++++++++++++++++++
 src/test/njs_unit_test.c |   4 ++--
 2 files changed, 22 insertions(+), 2 deletions(-)

diffs (51 lines):

diff -r 21b7a2d31852 -r ab443df0d924 auto/clang
--- a/auto/clang	Tue Aug 13 15:15:42 2019 +0300
+++ b/auto/clang	Tue Aug 13 16:04:10 2019 +0300
@@ -291,6 +291,26 @@ njs_feature_test="int n __attribute__ ((
 . auto/feature
 
 
+njs_feature="Address sanitizer"
+njs_feature_name=NJS_HAVE_ADDRESS_SANITIZER
+njs_feature_run=no
+njs_feature_path=
+njs_feature_libs=
+njs_feature_test="int main(void) {
+                      return
+                  #ifdef __SANITIZE_ADDRESS__
+                          0;
+                  #else
+                      #if defined(__has_feature)
+                          #if __has_feature(address_sanitizer)
+                          0;
+                          #endif
+                      #endif
+                  #endif
+                  }"
+. auto/feature
+
+
 njs_feature="Memory sanitizer"
 njs_feature_name=NJS_HAVE_MEMORY_SANITIZER
 njs_feature_run=yes
diff -r 21b7a2d31852 -r ab443df0d924 src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c	Tue Aug 13 15:15:42 2019 +0300
+++ b/src/test/njs_unit_test.c	Tue Aug 13 16:04:10 2019 +0300
@@ -4163,7 +4163,7 @@ static njs_unit_test_t  njs_test[] =
                  "Array.prototype.fill.call(o, 2).a"),
       njs_str("4") },
 
-#if (!NJS_HAVE_MEMORY_SANITIZER) /* MSAN limits stack size */
+#if (!NJS_HAVE_ADDRESS_SANITIZER && !NJS_HAVE_MEMORY_SANITIZER) /* limited stack size */
     { njs_str("var o = Object({length: 3});"
                  "Object.defineProperty(o, '0', {set: function(v){this[0] = 2 * v}});"
                  "Array.prototype.fill.call(o, 2)"),
@@ -6421,7 +6421,7 @@ static njs_unit_test_t  njs_test[] =
     { njs_str("{ function f() {} { var f }}"),
       njs_str("SyntaxError: \"f\" has already been declared in 1") },
 
-#if (!NJS_HAVE_MEMORY_SANITIZER) /* MSAN limits stack size */
+#if (!NJS_HAVE_ADDRESS_SANITIZER && !NJS_HAVE_MEMORY_SANITIZER) /* limited stack size */
     { njs_str("function f() { return f() } f()"),
       njs_str("RangeError: Maximum call stack size exceeded") },
 #endif


More information about the nginx-devel mailing list