diff mbox series

configure: add support for memory sanitizer (--enable-msan)

Message ID 20200317231837.39648-1-maennich@google.com
State Committed
Headers show
Series configure: add support for memory sanitizer (--enable-msan) | expand

Commit Message

Matthias Maennich March 17, 2020, 11:18 p.m. UTC
Similarly to asan, tsan and ubsan, add support for msan conditionally at
configure time. This allows us to track down issues caused by using
uninitialized values.

        * configure.ac: Add configure options for -fsanitize=memory

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 configure.ac | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Dodji Seketeli March 18, 2020, 9:45 p.m. UTC | #1
Matthias,

Matthias Maennich <maennich@google.com> a ?crit:

> Similarly to asan, tsan and ubsan, add support for msan conditionally at
> configure time. This allows us to track down issues caused by using
> uninitialized values.
>
>         * configure.ac: Add configure options for -fsanitize=memory

Applied to master.

Thanks!
diff mbox series

Patch

diff --git a/configure.ac b/configure.ac
index 50a50c6c8932..9f30ea38cf86 100644
--- a/configure.ac
+++ b/configure.ac
@@ -120,6 +120,12 @@  AC_ARG_ENABLE(asan,
 	      ENABLE_ASAN=$enableval,
 	      ENABLE_ASAN=no)
 
+AC_ARG_ENABLE(msan,
+	      AS_HELP_STRING([--enable-msan=yes|no],
+			     [enable the support of building with -fsanitize=memory)]),
+	      ENABLE_MSAN=$enableval,
+	      ENABLE_MSAN=no)
+
 AC_ARG_ENABLE(tsan,
 	      AS_HELP_STRING([--enable-tsan=yes|no],
 			     [enable the support of building with -fsanitize=thread)]),
@@ -620,6 +626,11 @@  if test x$ENABLE_ASAN = xyes; then
     CXXFLAGS="$CXXFLAGS -fsanitize=address"
 fi
 
+if test x$ENABLE_MSAN = xyes; then
+    CFLAGS="$CFLAGS -fsanitize=memory -fsanitize-memory-track-origins"
+    CXXFLAGS="$CXXFLAGS -fsanitize=memory -fsanitize-memory-track-origins"
+fi
+
 if test x$ENABLE_TSAN = xyes; then
     CFLAGS="$CFLAGS -fsanitize=thread"
     CXXFLAGS="$CXXFLAGS -fsanitize=thread"
@@ -918,6 +929,7 @@  AC_MSG_NOTICE([
     Enable python 3				   : ${ENABLE_PYTHON3}
     Enable running tests under Valgrind            : ${enable_valgrind}
     Enable build with -fsanitize=address    	   : ${ENABLE_ASAN}
+    Enable build with -fsanitize=memory    	   : ${ENABLE_MSAN}
     Enable build with -fsanitize=thread    	   : ${ENABLE_TSAN}
     Enable build with -fsanitize=undefined  	   : ${ENABLE_UBSAN}
     Generate html apidoc	                   : ${ENABLE_APIDOC}