Skip to content

Commit 54dd762

Browse files
committed
Set up asan+ubsan scheduled build on azure
Also adds an --asan flag to run-tests.php to setup all the necessary environment variables. Some tests are marked as skipped because they are incompatible with asan or too slow. I'm basing this on the DEBUG_ZTS build, which seems to give us the most mileage.
1 parent ca6f41a commit 54dd762

21 files changed

+78
-5
lines changed

Zend/tests/concat_003.phpt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
--TEST--
22
Concatenating many small strings should not slowdown allocations
33
--SKIPIF--
4-
<?php if (PHP_DEBUG) { die ("skip debug version is slow"); } ?>
4+
<?php
5+
if (PHP_DEBUG) { die ("skip debug version is slow"); }
6+
if (getenv('SKIP_PERF_SENSITIVE')) die("skip performance sensitive test");
7+
?>
58
--FILE--
69
<?php
710

azure-pipelines.yml

+9
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,12 @@ jobs:
5555
parameters:
5656
configurationName: MACOS_RELEASE_ZTS
5757
configurationParameters: '--disable-debug --enable-maintainer-zts'
58+
- template: azure/job.yml
59+
parameters:
60+
configurationName: DEBUG_ZTS_ASAN_UBSAN
61+
configurationParameters: >-
62+
--enable-debug --enable-maintainer-zts
63+
CFLAGS='-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC'
64+
LDFLAGS='-fsanitize=undefined,address'
65+
runTestsParameters: --asan
66+
timeoutInMinutes: 120

azure/job.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
parameters:
22
configurationName: ''
33
configurationParameters: ''
4+
runTestsParameters: ''
5+
timeoutInMinutes: 60
46

57
jobs:
68
- job: ${{ parameters.configurationName }}
9+
timeoutInMinutes: ${{ parameters.timeoutInMinutes }}
710
pool:
811
vmImage: 'ubuntu-latest'
912
steps:
@@ -80,8 +83,11 @@ jobs:
8083
- template: test.yml
8184
parameters:
8285
configurationName: ${{ parameters.configurationName }}
86+
runTestsParameters: ${{ parameters.runTestsParameters }}
8387
- template: test.yml
8488
parameters:
8589
configurationName: ${{ parameters.configurationName }}
8690
runTestsName: 'OpCache'
87-
runTestsParameters: -d zend_extension=opcache.so -d opcache.enable_cli=1
91+
runTestsParameters: >-
92+
${{ parameters.runTestsParameters }}
93+
-d zend_extension=opcache.so -d opcache.enable_cli=1

azure/lsan-suppressions.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
leak:acommon::DictInfoList::elements

ext/fileinfo/tests/cve-2014-3538-nojit.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Bug #66731: file: extensive backtraking, with pcre.jit=0
44
<?php
55
if (defined("PHP_DEBUG") && PHP_DEBUG)
66
die("skip not suitable for debug build");
7+
if (getenv('SKIP_PERF_SENSITIVE'))
8+
die("skip performance sensitive test");
79
if (!class_exists('finfo'))
810
die('skip no fileinfo extension');
911
?>

ext/opcache/tests/log_verbosity_bug.phpt

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ opcache.file_cache_fallback=0
1212
opcache.memory_consumption=999999999
1313
opcache.log_verbosity_level=-1
1414
--SKIPIF--
15-
<?php require_once('skipif.inc'); ?>
15+
<?php
16+
require_once('skipif.inc');
17+
if (getenv('SKIP_ASAN')) die('xfail Startup failure leak');
18+
?>
1619
--FILE--
1720
<?php
1821
var_dump("Script should fail");

ext/opcache/tests/preload_006.phpt

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ opcache.enable_cli=1
66
opcache.optimization_level=-1
77
opcache.preload={PWD}/preload_inheritance_error_ind.inc
88
--SKIPIF--
9-
<?php require_once('skipif.inc'); ?>
9+
<?php
10+
require_once('skipif.inc');
11+
if (getenv('SKIP_ASAN')) die('xfail Startup failure leak');
12+
?>
1013
--FILE--
1114
<?php
1215
echo "Foobar\n";

ext/pcntl/tests/pcntl_unshare_02.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ if (!extension_loaded("pcntl")) die("skip");
66
if (!extension_loaded("posix")) die("skip posix extension not available");
77
if (!function_exists("pcntl_unshare")) die("skip pcntl_unshare is not available");
88
if (!defined("CLONE_NEWPID")) die("skip flag unavailable");
9+
if (getenv("SKIP_ASAN")) die("skip asan chokes on this");
910
if (posix_getuid() !== 0 &&
1011
(!defined("CLONE_NEWUSER") ||
1112
(pcntl_unshare(CLONE_NEWUSER) == false && pcntl_get_last_error() == PCNTL_EPERM))) {

ext/pcre/tests/bug72685.phpt

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
--TEST--
22
Bug #72685: Same string is UTF-8 validated repeatedly
3+
--SKIPIF--
4+
<?php
5+
if (getenv('SKIP_PERF_SENSITIVE')) die("skip performance sensitive test");
6+
?>
37
--FILE--
48
<?php
59

ext/pspell/tests/005.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pspell configs
44
<?php
55
if (!extension_loaded('pspell')) die('skip');
66
if (!@pspell_new('en')) die('skip English dictionary is not available');
7+
if (getenv('SKIP_ASAN')) die('skip pspell leaks memory for invalid dicationaries');
78
?>
89
--FILE--
910
<?php

ext/standard/tests/general_functions/get_cfg_var_variation8.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Francesco Fullone [email protected]
55
#PHPTestFest Cesena Italia on 2009-06-20
66
--INI--
77
magic_quotes_gpc=1
8+
--SKIPIF--
9+
<?php if (getenv('SKIP_ASAN')) die('xfail Startup failure leak'); ?>
810
--FILE--
911
<?php
1012
echo "*** Test by calling method or function with deprecated option ***\n";

ext/xsl/tests/bug33853.phpt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
--TEST--
22
Bug #33853 (php:function call __autoload with lowercase param)
33
--SKIPIF--
4-
<?php if (!extension_loaded('xsl')) die('skip xsl not loaded'); ?>
4+
<?php
5+
if (!extension_loaded('xsl')) die('skip xsl not loaded');
6+
if (getenv('SKIP_ASAN')) die('xfail bailing out across foreign C code');
7+
?>
58
--FILE--
69
<?php
710

run-tests.php

+12
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,18 @@ function main()
517517
case '--shuffle':
518518
$shuffle = true;
519519
break;
520+
case '--asan':
521+
$environment['USE_ZEND_ALLOC'] = 0;
522+
$environment['USE_TRACKED_ALLOC'] = 1;
523+
$environment['SKIP_ASAN'] = 1;
524+
$environment['SKIP_PERF_SENSITIVE'] = 1;
525+
526+
$lsanSuppressions = __DIR__ . '/azure/lsan-suppressions.txt';
527+
if (file_exists($lsanSuppressions)) {
528+
$environment['LSAN_OPTIONS'] = 'suppressions=' . $lsanSuppressions
529+
. ':print_suppressions=0';
530+
}
531+
break;
520532
//case 'w'
521533
case '-':
522534
// repeat check with full switch

sapi/cli/tests/upload_2G.phpt

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ if (empty($enough_free_ram)) {
2525
if (getenv('TRAVIS')) {
2626
die("skip Fails intermittently on travis");
2727
}
28+
29+
if (getenv('SKIP_PERF_SENSITIVE')) {
30+
die("skip Test may be very slow if PHP is instrumented");
31+
}
2832
?>
2933
--FILE--
3034
<?php

sapi/fpm/tests/bug68381-log-level-warning.phpt

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FPM: bug68381 - Log messages with warning level only
33
--SKIPIF--
44
<?php
55
include "skipif.inc";
6+
if (getenv("SKIP_ASAN")) die("skip Often fails on azure with asan for unknown reason");
67
?>
78
--FILE--
89
<?php

sapi/phpdbg/tests/watch_001.phpt

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Test simple recursive watchpoint
55
if (PHP_INT_SIZE == 4) {
66
die("xfail There may be flaws in the implementation of watchpoints that cause failures");
77
}
8+
if (getenv('SKIP_ASAN')) {
9+
die("skip intentionally causes segfaults");
10+
}
811
?>
912
--INI--
1013
opcache.optimization_level=0

sapi/phpdbg/tests/watch_002.phpt

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Test simple array watchpoint with replace
55
if (PHP_INT_SIZE == 4) {
66
die("xfail There may be flaws in the implementation of watchpoints that cause failures");
77
}
8+
if (getenv('SKIP_ASAN')) {
9+
die("skip intentionally causes segfaults");
10+
}
811
?>
912
--PHPDBG--
1013
b 6

sapi/phpdbg/tests/watch_003.phpt

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Test simple watchpoint with replace
55
if (PHP_INT_SIZE == 4) {
66
die("xfail There may be flaws in the implementation of watchpoints that cause failures");
77
}
8+
if (getenv('SKIP_ASAN')) {
9+
die("skip intentionally causes segfaults");
10+
}
811
?>
912
--PHPDBG--
1013
b 6

sapi/phpdbg/tests/watch_004.phpt

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Test detection of inline string manipulations on zval watch
55
if (PHP_INT_SIZE == 4) {
66
die("xfail There may be flaws in the implementation of watchpoints that cause failures");
77
}
8+
if (getenv('SKIP_ASAN')) {
9+
die("skip intentionally causes segfaults");
10+
}
811
?>
912
--INI--
1013
opcache.optimization_level=0

sapi/phpdbg/tests/watch_005.phpt

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Test proper watch comparisons when having multiple levels of indirection from a
55
if (PHP_INT_SIZE == 4) {
66
die("xfail There may be flaws in the implementation of watchpoints that cause failures");
77
}
8+
if (getenv('SKIP_ASAN')) {
9+
die("skip intentionally causes segfaults");
10+
}
811
?>
912
--PHPDBG--
1013
b 3

sapi/phpdbg/tests/watch_006.phpt

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Test multiple watch elements pointing to the same watchpoint
55
if (PHP_INT_SIZE == 4) {
66
die("xfail There may be flaws in the implementation of watchpoints that cause failures");
77
}
8+
if (getenv('SKIP_ASAN')) {
9+
die("skip intentionally causes segfaults");
10+
}
811
?>
912
--PHPDBG--
1013
b 4

0 commit comments

Comments
 (0)