Skip to content

Commit 50f58c8

Browse files
committed
Add ASAN XLEAK support
Only disable LSAN instead of skipping the test. This way we can still detect memory issues which is arguably more important anyway. Closes GH-10996
1 parent c211e67 commit 50f58c8

17 files changed

+27
-18
lines changed

ext/enchant/tests/dict_quick_check.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ marcosptf - <[email protected]>
66
enchant
77
--SKIPIF--
88
<?php
9-
if (getenv('SKIP_ASAN')) die('skip Known libenchant memory leak');
9+
if (getenv('SKIP_ASAN')) die('xleak Known libenchant memory leak');
1010
if (!is_object(enchant_broker_init())) {die("skip, resource dont load\n");}
1111
if (!is_array(enchant_broker_list_dicts(enchant_broker_init()))) {die("skip, no dictionary installed on this machine! \n");}
1212

ext/ffi/tests/bug79576.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Bug #79576 ("TYPE *" shows unhelpful message when type is not defined)
44
ffi
55
--SKIPIF--
66
<?php
7-
if (PHP_DEBUG || getenv('SKIP_ASAN')) echo "xfail: FFI cleanup after parser error is nor implemented";
7+
if (PHP_DEBUG || getenv('SKIP_ASAN')) echo "xleak FFI cleanup after parser error is nor implemented";
88
?>
99
--FILE--
1010
<?php

ext/imap/tests/imap_getsubscribed_basic.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ imap
77
--SKIPIF--
88
<?php
99
require_once(__DIR__.'/setup/skipif.inc');
10-
if (getenv("SKIP_ASAN")) die("skip asan chokes on this: 'LeakSanitizer does not work under ptrace (strace, gdb, etc)'");
10+
if (getenv("SKIP_ASAN")) die("xleak asan chokes on this: 'LeakSanitizer does not work under ptrace (strace, gdb, etc)'");
1111
?>
1212
--CONFLICTS--
1313
defaultmailbox

ext/imap/tests/imap_lsub_basic.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ imap
77
--SKIPIF--
88
<?php
99
require_once(__DIR__.'/setup/skipif.inc');
10-
if (getenv("SKIP_ASAN")) die("skip leak sanitizer crashes");
10+
if (getenv("SKIP_ASAN")) die("xleak leak sanitizer crashes");
1111
?>
1212
--CONFLICTS--
1313
defaultmailbox

ext/imap/tests/imap_open_error.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ imap
88
--SKIPIF--
99
<?php
1010
require_once(__DIR__.'/setup/skipif.inc');
11-
if (getenv("SKIP_ASAN")) die("skip leak sanitizer crashes");
11+
if (getenv("SKIP_ASAN")) die("xleak leak sanitizer crashes");
1212
?>
1313
--FILE--
1414
<?php

ext/oci8/tests/privileged_connect1.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ privileged connect tests
44
oci8
55
--SKIPIF--
66
<?php
7-
if (getenv('SKIP_ASAN')) die('skip leaks memory under asan');
7+
if (getenv('SKIP_ASAN')) die('xleak leaks memory under asan');
88
?>
99
--INI--
1010
oci8.privileged_connect=1

ext/opcache/tests/gh9259_003.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Bug GH-9259 003 (Setting opcache.interned_strings_buffer to a very high value le
44
opcache
55
--SKIPIF--
66
<?php
7-
if (getenv('SKIP_ASAN')) die('xfail Leaks memory with ASAN');
7+
if (getenv('SKIP_ASAN')) die('xleak Leaks memory with ASAN');
88
?>
99
--INI--
1010
opcache.interned_strings_buffer=500

ext/opcache/tests/log_verbosity_bug.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ opcache.log_verbosity_level=-1
1414
opcache
1515
--SKIPIF--
1616
<?php
17-
if (getenv('SKIP_ASAN')) die('xfail Startup failure leak');
17+
if (getenv('SKIP_ASAN')) die('xleak Startup failure leak');
1818
?>
1919
--FILE--
2020
<?php

ext/opcache/tests/preload_006.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ opcache
1010
--SKIPIF--
1111
<?php
1212
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
13-
if (getenv('SKIP_ASAN')) die('xfail Startup failure leak');
13+
if (getenv('SKIP_ASAN')) die('xleak Startup failure leak');
1414
?>
1515
--FILE--
1616
<?php

ext/opcache/tests/preload_parse_error.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ opcache
1010
--SKIPIF--
1111
<?php
1212
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
13-
if (getenv('SKIP_ASAN')) die('xfail Startup failure leak');
13+
if (getenv('SKIP_ASAN')) die('xleak Startup failure leak');
1414
?>
1515
--FILE--
1616
OK

ext/pdo_oci/tests/pecl_bug_6364.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pdo
55
pdo_oci
66
--SKIPIF--
77
<?php
8-
if (getenv('SKIP_ASAN')) die('skip leaks memory under asan');
8+
if (getenv('SKIP_ASAN')) die('xleak leaks memory under asan');
99
require(__DIR__.'/../../pdo/tests/pdo_test.inc');
1010
PDOTest::skip();
1111
?>

ext/posix/tests/posix_getgrgid_error.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Test posix_getgrgid() function : error conditions
44
posix
55
--SKIPIF--
66
<?php
7-
if (getenv('SKIP_ASAN')) die('skip LSan crashes when firebird is loaded');
7+
if (getenv('SKIP_ASAN')) die('xleak LSan crashes when firebird is loaded');
88
?>
99
--FILE--
1010
<?php

ext/posix/tests/posix_getpwuid_error.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Test posix_getpwuid() function : error conditions
44
posix
55
--SKIPIF--
66
<?php
7-
if (getenv('SKIP_ASAN')) die('skip LSan crashes when firebird is loaded');
7+
if (getenv('SKIP_ASAN')) die('xleak LSan crashes when firebird is loaded');
88
?>
99
--FILE--
1010
<?php

ext/pspell/tests/005.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pspell
55
--SKIPIF--
66
<?php
77
if (!@pspell_new('en')) die('skip English dictionary is not available');
8-
if (getenv('SKIP_ASAN')) die('skip pspell leaks memory for invalid dicationaries');
8+
if (getenv('SKIP_ASAN')) die('xleak pspell leaks memory for invalid dicationaries');
99
?>
1010
--FILE--
1111
<?php

ext/standard/tests/general_functions/get_cfg_var_variation8.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Francesco Fullone [email protected]
66
--INI--
77
magic_quotes_gpc=1
88
--SKIPIF--
9-
<?php if (getenv('SKIP_ASAN')) die('xfail Startup failure leak'); ?>
9+
<?php if (getenv('SKIP_ASAN')) die('xleak Startup failure leak'); ?>
1010
--FILE--
1111
<?php
1212
echo "*** Test by calling method or function with deprecated option ***\n";

ext/standard/tests/streams/bug46024.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Bug #46024 stream_select() doesn't return the correct number
55
if (!getenv('TEST_PHP_EXECUTABLE_ESCAPED')) die("skip TEST_PHP_EXECUTABLE_ESCAPED not defined");
66
// Terminating the process may cause a bailout while writing out the phpinfo,
77
// which may leak a temporary hash table. This does not seems worth fixing.
8-
if (getenv('SKIP_ASAN')) die("skip Test may leak");
8+
if (getenv('SKIP_ASAN')) die("xleak Test may leak");
99
?>
1010
--FILE--
1111
<?php

run-tests.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -2207,6 +2207,9 @@ function run_test(string $php, $file, array $env): string
22072207
} elseif (!strncasecmp('xfail', $output, 5)) {
22082208
// Pretend we have an XFAIL section
22092209
$test->setSection('XFAIL', ltrim(substr($output, 5)));
2210+
} elseif (!strncasecmp('xleak', $output, 5)) {
2211+
// Pretend we have an XLEAK section
2212+
$test->setSection('XLEAK', ltrim(substr($output, 5)));
22102213
} elseif ($output !== '') {
22112214
show_result("BORK", $output, $tested_file, 'reason: invalid output from SKIPIF', $temp_filenames);
22122215
$PHP_FAILED_TESTS['BORKED'][] = [
@@ -2461,6 +2464,10 @@ function run_test(string $php, $file, array $env): string
24612464
$cmd = $valgrind->wrapCommand($cmd, $memcheck_filename, strpos($test_file, "pcre") !== false);
24622465
}
24632466

2467+
if ($test->hasSection('XLEAK') && isset($env['SKIP_ASAN'])) {
2468+
$env['LSAN_OPTIONS'] = 'detect_leaks=0';
2469+
}
2470+
24642471
if ($DETAILED) {
24652472
echo "
24662473
CONTENT_LENGTH = " . $env['CONTENT_LENGTH'] . "
@@ -2657,7 +2664,8 @@ function run_test(string $php, $file, array $env): string
26572664
if ($test->hasSection('XFAIL')) {
26582665
$warn = true;
26592666
$info = " (warn: XFAIL section but test passes)";
2660-
} elseif ($test->hasSection('XLEAK')) {
2667+
} elseif ($test->hasSection('XLEAK') && !isset($env['SKIP_ASAN'])) {
2668+
// XLEAK with ASAN completely disables LSAN so the test is expected to pass
26612669
$warn = true;
26622670
$info = " (warn: XLEAK section but test passes)";
26632671
} else {
@@ -2694,7 +2702,8 @@ function run_test(string $php, $file, array $env): string
26942702
if ($test->hasSection('XFAIL')) {
26952703
$restype[] = 'XFAIL';
26962704
$info = ' XFAIL REASON: ' . rtrim($test->getSection('XFAIL'));
2697-
} elseif ($test->hasSection('XLEAK')) {
2705+
} elseif ($test->hasSection('XLEAK') && !isset($env['SKIP_ASAN'])) {
2706+
// XLEAK with ASAN completely disables LSAN so the test is expected to pass
26982707
$restype[] = 'XLEAK';
26992708
$info = ' XLEAK REASON: ' . rtrim($test->getSection('XLEAK'));
27002709
} else {

0 commit comments

Comments
 (0)