]> granicus.if.org Git - php/commitdiff
Add --enable-memory-sanitizer flag
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 20 May 2020 13:21:01 +0000 (15:21 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 20 May 2020 14:46:28 +0000 (16:46 +0200)
This flag enabled msan late in the pipeline, so that it does
not affect configure checks.

Otherwise we get a false positive report for openpty availability
without -lutil, which will then result in infinite recursion if
actually called.

This also sets origin tracking to 2, so bump the timeout to 90
minutes.

azure-pipelines.yml
azure/msan_job.yml
configure.ac

index 40cfbb82327f93467f65f47ac925a0a14d468a0e..178558ab11107355e8a3f51e60e8c34dae30b7b7 100644 (file)
@@ -75,6 +75,7 @@ jobs:
         configurationName: DEBUG_ZTS_MSAN
         configurationParameters: '--enable-debug --enable-zts'
         runTestsParameters: --asan
+        timeoutInMinutes: 90
     - template: azure/community_job.yml
       parameters:
         configurationName: COMMUNITY
index 3c58fa7c7a3e25107e30c9a6631699d7a8d0cda2..399a664f5ecbc97269b2411432e17cd9ac534120 100644 (file)
@@ -14,8 +14,7 @@ jobs:
     - script: |
         export CC=clang
         export CXX=clang++
-        export CFLAGS="-fsanitize=memory -DZEND_TRACK_ARENA_ALLOC"
-        export LDFLAGS="-fsanitize=memory"
+        export CFLAGS="-DZEND_TRACK_ARENA_ALLOC"
         ./buildconf --force
         # msan requires all used libraries to be instrumented,
         # so we should avoiding linking against anything but libc here
@@ -50,6 +49,7 @@ jobs:
             --enable-ftp \
             --enable-zend-test \
             --enable-werror \
+            --enable-memory-sanitizer \
             --with-config-file-path=/etc \
             --with-config-file-scan-dir=/etc/php.d
       displayName: 'Configure Build'
index 5278718f1a7e34b0b7d0b019136c2d18d44d5cb0..2c3928b6a9678e791b05dfa97ffca2e2f7cc0615 100644 (file)
@@ -974,6 +974,11 @@ PHP_ARG_ENABLE([werror],,
     [Enable -Werror])],
   [no],
   [no])
+PHP_ARG_ENABLE([memory-sanitizer],,
+  [AS_HELP_STRING([--enable-memory-sanitizer],
+    [Enable memory sanitizer (clang only)])],
+  [no],
+  [no])
 
 dnl Extension configuration.
 dnl ----------------------------------------------------------------------------
@@ -1369,9 +1374,16 @@ if test "$PHP_THREAD_SAFETY" = "yes" && test -n "$ac_cv_pthreads_cflags"; then
   CPPFLAGS="$CPPFLAGS $ac_cv_pthreads_cflags"
 fi
 
+dnl Enable -Werror late, because it may break configure checks throwing warnings.
 if test "$PHP_WERROR" = "yes"; then
   CFLAGS="$CFLAGS -Werror"
-  CPPFLAGS="$CPPFLAGS -Werror"
+  CXXFLAGS="$CXXFLAGS -Werror"
+fi
+
+dnl Enable -fsanitize=memory late, because interceptors may break linking detection.
+if test "$PHP_MEMORY_SANITIZER" = "yes"; then
+  CFLAGS="$CFLAGS -fsanitize=memory -fsanitize-memory-track-origins"
+  CXXFLAGS="$CXXFLAGS -fsanitize=memory -fsanitize-memory-track-origins"
 fi
 
 dnl