Skip to content

Commit e852944

Browse files
committed
Add --enable-memory-sanitizer flag
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.
1 parent c85ded7 commit e852944

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ jobs:
7575
configurationName: DEBUG_ZTS_MSAN
7676
configurationParameters: '--enable-debug --enable-zts'
7777
runTestsParameters: --asan
78+
timeoutInMinutes: 90
7879
- template: azure/community_job.yml
7980
parameters:
8081
configurationName: COMMUNITY

azure/msan_job.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ jobs:
1414
- script: |
1515
export CC=clang
1616
export CXX=clang++
17-
export CFLAGS="-fsanitize=memory -DZEND_TRACK_ARENA_ALLOC"
18-
export LDFLAGS="-fsanitize=memory"
17+
export CFLAGS="-DZEND_TRACK_ARENA_ALLOC"
1918
./buildconf --force
2019
# msan requires all used libraries to be instrumented,
2120
# so we should avoiding linking against anything but libc here
@@ -50,6 +49,7 @@ jobs:
5049
--enable-ftp \
5150
--enable-zend-test \
5251
--enable-werror \
52+
--enable-memory-sanitizer \
5353
--with-config-file-path=/etc \
5454
--with-config-file-scan-dir=/etc/php.d
5555
displayName: 'Configure Build'

configure.ac

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,11 @@ PHP_ARG_ENABLE([werror],,
974974
[Enable -Werror])],
975975
[no],
976976
[no])
977+
PHP_ARG_ENABLE([memory-sanitizer],,
978+
[AS_HELP_STRING([--enable-memory-sanitizer],
979+
[Enable memory sanitizer (clang only)])],
980+
[no],
981+
[no])
977982

978983
dnl Extension configuration.
979984
dnl ----------------------------------------------------------------------------
@@ -1369,9 +1374,16 @@ if test "$PHP_THREAD_SAFETY" = "yes" && test -n "$ac_cv_pthreads_cflags"; then
13691374
CPPFLAGS="$CPPFLAGS $ac_cv_pthreads_cflags"
13701375
fi
13711376

1377+
dnl Enable -Werror late, because it may break configure checks throwing warnings.
13721378
if test "$PHP_WERROR" = "yes"; then
13731379
CFLAGS="$CFLAGS -Werror"
1374-
CPPFLAGS="$CPPFLAGS -Werror"
1380+
CXXFLAGS="$CXXFLAGS -Werror"
1381+
fi
1382+
1383+
dnl Enable -fsanitize=memory late, because interceptors may break linking detection.
1384+
if test "$PHP_MEMORY_SANITIZER" = "yes"; then
1385+
CFLAGS="$CFLAGS -fsanitize=memory -fsanitize-memory-track-origins"
1386+
CXXFLAGS="$CXXFLAGS -fsanitize=memory -fsanitize-memory-track-origins"
13751387
fi
13761388

13771389
dnl

0 commit comments

Comments
 (0)