Add support for Memory sanitizer (#1652)
This commit is contained in:
@@ -227,6 +227,13 @@ jobs:
|
|||||||
pcre: "--with-pcre"
|
pcre: "--with-pcre"
|
||||||
maxminddb: "--with-maxminddb"
|
maxminddb: "--with-maxminddb"
|
||||||
msan: "--with-thread-sanitizer"
|
msan: "--with-thread-sanitizer"
|
||||||
|
- compiler: "clang-12"
|
||||||
|
os: ubuntu-latest
|
||||||
|
arch: "x86_64"
|
||||||
|
gcrypt: ""
|
||||||
|
pcre: "--with-pcre"
|
||||||
|
maxminddb: "--with-maxminddb"
|
||||||
|
msan: "--with-memory-sanitizer"
|
||||||
- compiler: "cc"
|
- compiler: "cc"
|
||||||
os: ubuntu-18.04
|
os: ubuntu-18.04
|
||||||
arch: "x86_64"
|
arch: "x86_64"
|
||||||
@@ -391,7 +398,8 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
./tests/do.sh
|
./tests/do.sh
|
||||||
- name: Test nDPI [UNIT]
|
- name: Test nDPI [UNIT]
|
||||||
if: startsWith(matrix.arch, 'x86_64') && !startsWith(matrix.os, 'windows')
|
#Some issues with masan + json-c. Disable the test as workaround
|
||||||
|
if: startsWith(matrix.arch, 'x86_64') && !startsWith(matrix.os, 'windows') && !startsWith(matrix.msan, '--with-memory-sanitizer')
|
||||||
run: |
|
run: |
|
||||||
./tests/do-unit.sh
|
./tests/do-unit.sh
|
||||||
- name: Test nDPI [DGA]
|
- name: Test nDPI [DGA]
|
||||||
|
|||||||
+15
-3
@@ -15,6 +15,7 @@ AS_IF([test "${with_only_libndpi+set}" = set],[
|
|||||||
|
|
||||||
AC_ARG_WITH(sanitizer, AS_HELP_STRING([--with-sanitizer], [Build with support for address, undefined and leak sanitizer]))
|
AC_ARG_WITH(sanitizer, AS_HELP_STRING([--with-sanitizer], [Build with support for address, undefined and leak sanitizer]))
|
||||||
AC_ARG_WITH(thread-sanitizer, AS_HELP_STRING([--with-thread-sanitizer], [Build with support for thread sanitizer]))
|
AC_ARG_WITH(thread-sanitizer, AS_HELP_STRING([--with-thread-sanitizer], [Build with support for thread sanitizer]))
|
||||||
|
AC_ARG_WITH(memory-sanitizer, AS_HELP_STRING([--with-memory-sanitizer], [Build with support for memory sanitizer]))
|
||||||
AC_ARG_ENABLE(fuzztargets, AS_HELP_STRING([--enable-fuzztargets], [Enable fuzz targets]),[enable_fuzztargets=$enableval],[enable_fuzztargets=no])
|
AC_ARG_ENABLE(fuzztargets, AS_HELP_STRING([--enable-fuzztargets], [Enable fuzz targets]),[enable_fuzztargets=$enableval],[enable_fuzztargets=no])
|
||||||
AC_ARG_ENABLE(gprof, AS_HELP_STRING([--enable-gprof], [Enable CPU/HEAP profiling with gperftools]),[enable_gprof=$enableval],[enable_gprof=no])
|
AC_ARG_ENABLE(gprof, AS_HELP_STRING([--enable-gprof], [Enable CPU/HEAP profiling with gperftools]),[enable_gprof=$enableval],[enable_gprof=no])
|
||||||
AC_ARG_ENABLE(code-coverage, AS_HELP_STRING([--enable-code-coverage], [Generate Code Coverage report]))
|
AC_ARG_ENABLE(code-coverage, AS_HELP_STRING([--enable-code-coverage], [Generate Code Coverage report]))
|
||||||
@@ -28,14 +29,20 @@ AM_CONDITIONAL([BUILD_FUZZTARGETS], [test "x$enable_fuzztargets" = "xyes"])
|
|||||||
AS_IF([test "${with_sanitizer+set}" = set -a "${with_thread_sanitizer+set}" = set],[
|
AS_IF([test "${with_sanitizer+set}" = set -a "${with_thread_sanitizer+set}" = set],[
|
||||||
AC_MSG_ERROR([Configure options `--with-sanitizer' and `--with_thread_sanitizer' can not used at the same time.])
|
AC_MSG_ERROR([Configure options `--with-sanitizer' and `--with_thread_sanitizer' can not used at the same time.])
|
||||||
])
|
])
|
||||||
AS_IF([test "${with_sanitizer+set}" = set -o "${with_thread_sanitizer+set}" = set],[
|
AS_IF([test "${with_sanitizer+set}" = set -a "${with_memory_sanitizer+set}" = set],[
|
||||||
|
AC_MSG_ERROR([Configure options `--with-sanitizer' and `--with_memory_sanitizer' can not used at the same time.])
|
||||||
|
])
|
||||||
|
AS_IF([test "${with_thread_sanitizer+set}" = set -a "${with_memory_sanitizer+set}" = set],[
|
||||||
|
AC_MSG_ERROR([Configure options `--with_thread_sanitizer' and `--with_memory_sanitizer' can not used at the same time.])
|
||||||
|
])
|
||||||
|
AS_IF([test "${with_sanitizer+set}" = set -o "${with_thread_sanitizer+set}" = set -o "${with_memory_sanitizer+set}" = set],[
|
||||||
NDPI_CFLAGS="${NDPI_CFLAGS} -O0 -g3"
|
NDPI_CFLAGS="${NDPI_CFLAGS} -O0 -g3"
|
||||||
],[
|
],[
|
||||||
NDPI_CFLAGS="${NDPI_CFLAGS} -O2"
|
NDPI_CFLAGS="${NDPI_CFLAGS} -O2"
|
||||||
])
|
])
|
||||||
AS_IF([test "${with_sanitizer+set}" = set -o "${with_thread_sanitizer+set}" = set],[
|
AS_IF([test "${with_sanitizer+set}" = set -o "${with_thread_sanitizer+set}" = set -o "${with_memory_sanitizer+set}" = set],[
|
||||||
AS_IF([test "x$enable_gprof" = "xyes"], [
|
AS_IF([test "x$enable_gprof" = "xyes"], [
|
||||||
AC_MSG_ERROR([Configure options `--with-sanitizer' / `--with_thread_sanitizer' can not used together with `--enable-gprof'.])
|
AC_MSG_ERROR([Configure options `--with-sanitizer' / `--with_thread_sanitizer' / `--with_memory_sanitizer' can not used together with `--enable-gprof'.])
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -49,6 +56,11 @@ AS_IF([test "${with_thread_sanitizer+set}" = set],[
|
|||||||
NDPI_LDFLAGS="${NDPI_LDFLAGS} -fsanitize=thread"
|
NDPI_LDFLAGS="${NDPI_LDFLAGS} -fsanitize=thread"
|
||||||
])
|
])
|
||||||
|
|
||||||
|
AS_IF([test "${with_memory_sanitizer+set}" = set],[
|
||||||
|
NDPI_CFLAGS="${CFLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer"
|
||||||
|
NDPI_LDFLAGS="${LDFLAGS} -fsanitize=memory"
|
||||||
|
])
|
||||||
|
|
||||||
AS_IF([test "x${enable_code_coverage}" = "xyes"],[
|
AS_IF([test "x${enable_code_coverage}" = "xyes"],[
|
||||||
NDPI_CFLAGS="${NDPI_CFLAGS} -fprofile-arcs -ftest-coverage"
|
NDPI_CFLAGS="${NDPI_CFLAGS} -fprofile-arcs -ftest-coverage"
|
||||||
NDPI_LDFLAGS="${NDPI_LDFLAGS} --coverage"
|
NDPI_LDFLAGS="${NDPI_LDFLAGS} --coverage"
|
||||||
|
|||||||
+4
-1
@@ -25,7 +25,10 @@
|
|||||||
|
|
||||||
#if defined(__has_feature)
|
#if defined(__has_feature)
|
||||||
#if __has_feature(memory_sanitizer)
|
#if __has_feature(memory_sanitizer)
|
||||||
#warning "MBEDTLS_AESNI_C is known to cause spurious error reports with some memory sanitizers as they do not understand the assembly code."
|
/* Using "#pragma message" instead of "#warning" to allow compilation with -Werror.
|
||||||
|
This pragma directive should be supported from every compilers supporting also memory sanitizer
|
||||||
|
*/
|
||||||
|
#pragma message "MBEDTLS_AESNI_C is known to cause spurious error reports with some memory sanitizers as they do not understand the assembly code."
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user