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
This commit is contained in:
Ilija Tovilo 2023-04-02 21:39:00 +02:00
parent c211e67b4e
commit 50f58c8923
No known key found for this signature in database
GPG key ID: A4F5D403F118200A
17 changed files with 27 additions and 18 deletions

View file

@ -6,7 +6,7 @@ marcosptf - <marcosptf@yahoo.com.br>
enchant enchant
--SKIPIF-- --SKIPIF--
<?php <?php
if (getenv('SKIP_ASAN')) die('skip Known libenchant memory leak'); if (getenv('SKIP_ASAN')) die('xleak Known libenchant memory leak');
if (!is_object(enchant_broker_init())) {die("skip, resource dont load\n");} if (!is_object(enchant_broker_init())) {die("skip, resource dont load\n");}
if (!is_array(enchant_broker_list_dicts(enchant_broker_init()))) {die("skip, no dictionary installed on this machine! \n");} if (!is_array(enchant_broker_list_dicts(enchant_broker_init()))) {die("skip, no dictionary installed on this machine! \n");}

View file

@ -4,7 +4,7 @@ Bug #79576 ("TYPE *" shows unhelpful message when type is not defined)
ffi ffi
--SKIPIF-- --SKIPIF--
<?php <?php
if (PHP_DEBUG || getenv('SKIP_ASAN')) echo "xfail: FFI cleanup after parser error is nor implemented"; if (PHP_DEBUG || getenv('SKIP_ASAN')) echo "xleak FFI cleanup after parser error is nor implemented";
?> ?>
--FILE-- --FILE--
<?php <?php

View file

@ -7,7 +7,7 @@ imap
--SKIPIF-- --SKIPIF--
<?php <?php
require_once(__DIR__.'/setup/skipif.inc'); require_once(__DIR__.'/setup/skipif.inc');
if (getenv("SKIP_ASAN")) die("skip asan chokes on this: 'LeakSanitizer does not work under ptrace (strace, gdb, etc)'"); if (getenv("SKIP_ASAN")) die("xleak asan chokes on this: 'LeakSanitizer does not work under ptrace (strace, gdb, etc)'");
?> ?>
--CONFLICTS-- --CONFLICTS--
defaultmailbox defaultmailbox

View file

@ -7,7 +7,7 @@ imap
--SKIPIF-- --SKIPIF--
<?php <?php
require_once(__DIR__.'/setup/skipif.inc'); require_once(__DIR__.'/setup/skipif.inc');
if (getenv("SKIP_ASAN")) die("skip leak sanitizer crashes"); if (getenv("SKIP_ASAN")) die("xleak leak sanitizer crashes");
?> ?>
--CONFLICTS-- --CONFLICTS--
defaultmailbox defaultmailbox

View file

@ -8,7 +8,7 @@ imap
--SKIPIF-- --SKIPIF--
<?php <?php
require_once(__DIR__.'/setup/skipif.inc'); require_once(__DIR__.'/setup/skipif.inc');
if (getenv("SKIP_ASAN")) die("skip leak sanitizer crashes"); if (getenv("SKIP_ASAN")) die("xleak leak sanitizer crashes");
?> ?>
--FILE-- --FILE--
<?php <?php

View file

@ -4,7 +4,7 @@ privileged connect tests
oci8 oci8
--SKIPIF-- --SKIPIF--
<?php <?php
if (getenv('SKIP_ASAN')) die('skip leaks memory under asan'); if (getenv('SKIP_ASAN')) die('xleak leaks memory under asan');
?> ?>
--INI-- --INI--
oci8.privileged_connect=1 oci8.privileged_connect=1

View file

@ -4,7 +4,7 @@ Bug GH-9259 003 (Setting opcache.interned_strings_buffer to a very high value le
opcache opcache
--SKIPIF-- --SKIPIF--
<?php <?php
if (getenv('SKIP_ASAN')) die('xfail Leaks memory with ASAN'); if (getenv('SKIP_ASAN')) die('xleak Leaks memory with ASAN');
?> ?>
--INI-- --INI--
opcache.interned_strings_buffer=500 opcache.interned_strings_buffer=500

View file

@ -14,7 +14,7 @@ opcache.log_verbosity_level=-1
opcache opcache
--SKIPIF-- --SKIPIF--
<?php <?php
if (getenv('SKIP_ASAN')) die('xfail Startup failure leak'); if (getenv('SKIP_ASAN')) die('xleak Startup failure leak');
?> ?>
--FILE-- --FILE--
<?php <?php

View file

@ -10,7 +10,7 @@ opcache
--SKIPIF-- --SKIPIF--
<?php <?php
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows'); if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
if (getenv('SKIP_ASAN')) die('xfail Startup failure leak'); if (getenv('SKIP_ASAN')) die('xleak Startup failure leak');
?> ?>
--FILE-- --FILE--
<?php <?php

View file

@ -10,7 +10,7 @@ opcache
--SKIPIF-- --SKIPIF--
<?php <?php
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows'); if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
if (getenv('SKIP_ASAN')) die('xfail Startup failure leak'); if (getenv('SKIP_ASAN')) die('xleak Startup failure leak');
?> ?>
--FILE-- --FILE--
OK OK

View file

@ -5,7 +5,7 @@ pdo
pdo_oci pdo_oci
--SKIPIF-- --SKIPIF--
<?php <?php
if (getenv('SKIP_ASAN')) die('skip leaks memory under asan'); if (getenv('SKIP_ASAN')) die('xleak leaks memory under asan');
require(__DIR__.'/../../pdo/tests/pdo_test.inc'); require(__DIR__.'/../../pdo/tests/pdo_test.inc');
PDOTest::skip(); PDOTest::skip();
?> ?>

View file

@ -4,7 +4,7 @@ Test posix_getgrgid() function : error conditions
posix posix
--SKIPIF-- --SKIPIF--
<?php <?php
if (getenv('SKIP_ASAN')) die('skip LSan crashes when firebird is loaded'); if (getenv('SKIP_ASAN')) die('xleak LSan crashes when firebird is loaded');
?> ?>
--FILE-- --FILE--
<?php <?php

View file

@ -4,7 +4,7 @@ Test posix_getpwuid() function : error conditions
posix posix
--SKIPIF-- --SKIPIF--
<?php <?php
if (getenv('SKIP_ASAN')) die('skip LSan crashes when firebird is loaded'); if (getenv('SKIP_ASAN')) die('xleak LSan crashes when firebird is loaded');
?> ?>
--FILE-- --FILE--
<?php <?php

View file

@ -5,7 +5,7 @@ pspell
--SKIPIF-- --SKIPIF--
<?php <?php
if (!@pspell_new('en')) die('skip English dictionary is not available'); if (!@pspell_new('en')) die('skip English dictionary is not available');
if (getenv('SKIP_ASAN')) die('skip pspell leaks memory for invalid dicationaries'); if (getenv('SKIP_ASAN')) die('xleak pspell leaks memory for invalid dicationaries');
?> ?>
--FILE-- --FILE--
<?php <?php

View file

@ -6,7 +6,7 @@ Francesco Fullone ff@ideato.it
--INI-- --INI--
magic_quotes_gpc=1 magic_quotes_gpc=1
--SKIPIF-- --SKIPIF--
<?php if (getenv('SKIP_ASAN')) die('xfail Startup failure leak'); ?> <?php if (getenv('SKIP_ASAN')) die('xleak Startup failure leak'); ?>
--FILE-- --FILE--
<?php <?php
echo "*** Test by calling method or function with deprecated option ***\n"; echo "*** Test by calling method or function with deprecated option ***\n";

View file

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

View file

@ -2207,6 +2207,9 @@ TEST $file
} elseif (!strncasecmp('xfail', $output, 5)) { } elseif (!strncasecmp('xfail', $output, 5)) {
// Pretend we have an XFAIL section // Pretend we have an XFAIL section
$test->setSection('XFAIL', ltrim(substr($output, 5))); $test->setSection('XFAIL', ltrim(substr($output, 5)));
} elseif (!strncasecmp('xleak', $output, 5)) {
// Pretend we have an XLEAK section
$test->setSection('XLEAK', ltrim(substr($output, 5)));
} elseif ($output !== '') { } elseif ($output !== '') {
show_result("BORK", $output, $tested_file, 'reason: invalid output from SKIPIF', $temp_filenames); show_result("BORK", $output, $tested_file, 'reason: invalid output from SKIPIF', $temp_filenames);
$PHP_FAILED_TESTS['BORKED'][] = [ $PHP_FAILED_TESTS['BORKED'][] = [
@ -2461,6 +2464,10 @@ TEST $file
$cmd = $valgrind->wrapCommand($cmd, $memcheck_filename, strpos($test_file, "pcre") !== false); $cmd = $valgrind->wrapCommand($cmd, $memcheck_filename, strpos($test_file, "pcre") !== false);
} }
if ($test->hasSection('XLEAK') && isset($env['SKIP_ASAN'])) {
$env['LSAN_OPTIONS'] = 'detect_leaks=0';
}
if ($DETAILED) { if ($DETAILED) {
echo " echo "
CONTENT_LENGTH = " . $env['CONTENT_LENGTH'] . " CONTENT_LENGTH = " . $env['CONTENT_LENGTH'] . "
@ -2657,7 +2664,8 @@ COMMAND $cmd
if ($test->hasSection('XFAIL')) { if ($test->hasSection('XFAIL')) {
$warn = true; $warn = true;
$info = " (warn: XFAIL section but test passes)"; $info = " (warn: XFAIL section but test passes)";
} elseif ($test->hasSection('XLEAK')) { } elseif ($test->hasSection('XLEAK') && !isset($env['SKIP_ASAN'])) {
// XLEAK with ASAN completely disables LSAN so the test is expected to pass
$warn = true; $warn = true;
$info = " (warn: XLEAK section but test passes)"; $info = " (warn: XLEAK section but test passes)";
} else { } else {
@ -2694,7 +2702,8 @@ COMMAND $cmd
if ($test->hasSection('XFAIL')) { if ($test->hasSection('XFAIL')) {
$restype[] = 'XFAIL'; $restype[] = 'XFAIL';
$info = ' XFAIL REASON: ' . rtrim($test->getSection('XFAIL')); $info = ' XFAIL REASON: ' . rtrim($test->getSection('XFAIL'));
} elseif ($test->hasSection('XLEAK')) { } elseif ($test->hasSection('XLEAK') && !isset($env['SKIP_ASAN'])) {
// XLEAK with ASAN completely disables LSAN so the test is expected to pass
$restype[] = 'XLEAK'; $restype[] = 'XLEAK';
$info = ' XLEAK REASON: ' . rtrim($test->getSection('XLEAK')); $info = ' XLEAK REASON: ' . rtrim($test->getSection('XLEAK'));
} else { } else {