From 50f58c8923c526a27c0898e8c69504beb1c005fd Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Sun, 2 Apr 2023 21:39:00 +0200 Subject: [PATCH] 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 --- ext/enchant/tests/dict_quick_check.phpt | 2 +- ext/ffi/tests/bug79576.phpt | 2 +- ext/imap/tests/imap_getsubscribed_basic.phpt | 2 +- ext/imap/tests/imap_lsub_basic.phpt | 2 +- ext/imap/tests/imap_open_error.phpt | 2 +- ext/oci8/tests/privileged_connect1.phpt | 2 +- ext/opcache/tests/gh9259_003.phpt | 2 +- ext/opcache/tests/log_verbosity_bug.phpt | 2 +- ext/opcache/tests/preload_006.phpt | 2 +- ext/opcache/tests/preload_parse_error.phpt | 2 +- ext/pdo_oci/tests/pecl_bug_6364.phpt | 2 +- ext/posix/tests/posix_getgrgid_error.phpt | 2 +- ext/posix/tests/posix_getpwuid_error.phpt | 2 +- ext/pspell/tests/005.phpt | 2 +- .../general_functions/get_cfg_var_variation8.phpt | 2 +- ext/standard/tests/streams/bug46024.phpt | 2 +- run-tests.php | 13 +++++++++++-- 17 files changed, 27 insertions(+), 18 deletions(-) diff --git a/ext/enchant/tests/dict_quick_check.phpt b/ext/enchant/tests/dict_quick_check.phpt index 3cc45079f24..b14a009af4c 100644 --- a/ext/enchant/tests/dict_quick_check.phpt +++ b/ext/enchant/tests/dict_quick_check.phpt @@ -6,7 +6,7 @@ marcosptf - enchant --SKIPIF-- --FILE-- --CONFLICTS-- defaultmailbox diff --git a/ext/imap/tests/imap_lsub_basic.phpt b/ext/imap/tests/imap_lsub_basic.phpt index e88aa6a8de4..bff521624e7 100644 --- a/ext/imap/tests/imap_lsub_basic.phpt +++ b/ext/imap/tests/imap_lsub_basic.phpt @@ -7,7 +7,7 @@ imap --SKIPIF-- --CONFLICTS-- defaultmailbox diff --git a/ext/imap/tests/imap_open_error.phpt b/ext/imap/tests/imap_open_error.phpt index 02ba0006e8c..18f0f2ef0fa 100644 --- a/ext/imap/tests/imap_open_error.phpt +++ b/ext/imap/tests/imap_open_error.phpt @@ -8,7 +8,7 @@ imap --SKIPIF-- --FILE-- --INI-- oci8.privileged_connect=1 diff --git a/ext/opcache/tests/gh9259_003.phpt b/ext/opcache/tests/gh9259_003.phpt index 1666f93257e..04dc46b1906 100644 --- a/ext/opcache/tests/gh9259_003.phpt +++ b/ext/opcache/tests/gh9259_003.phpt @@ -4,7 +4,7 @@ Bug GH-9259 003 (Setting opcache.interned_strings_buffer to a very high value le opcache --SKIPIF-- --INI-- opcache.interned_strings_buffer=500 diff --git a/ext/opcache/tests/log_verbosity_bug.phpt b/ext/opcache/tests/log_verbosity_bug.phpt index 6b7e04e2b8c..8467e4b3b8e 100644 --- a/ext/opcache/tests/log_verbosity_bug.phpt +++ b/ext/opcache/tests/log_verbosity_bug.phpt @@ -14,7 +14,7 @@ opcache.log_verbosity_level=-1 opcache --SKIPIF-- --FILE-- --FILE-- --FILE-- OK diff --git a/ext/pdo_oci/tests/pecl_bug_6364.phpt b/ext/pdo_oci/tests/pecl_bug_6364.phpt index 9a97496fd0f..afd3685a5b6 100644 --- a/ext/pdo_oci/tests/pecl_bug_6364.phpt +++ b/ext/pdo_oci/tests/pecl_bug_6364.phpt @@ -5,7 +5,7 @@ pdo pdo_oci --SKIPIF-- diff --git a/ext/posix/tests/posix_getgrgid_error.phpt b/ext/posix/tests/posix_getgrgid_error.phpt index 952a3894ef8..f0d49a7860f 100644 --- a/ext/posix/tests/posix_getgrgid_error.phpt +++ b/ext/posix/tests/posix_getgrgid_error.phpt @@ -4,7 +4,7 @@ Test posix_getgrgid() function : error conditions posix --SKIPIF-- --FILE-- --FILE-- --FILE-- + --FILE-- --FILE-- 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 !== '') { show_result("BORK", $output, $tested_file, 'reason: invalid output from SKIPIF', $temp_filenames); $PHP_FAILED_TESTS['BORKED'][] = [ @@ -2461,6 +2464,10 @@ TEST $file $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) { echo " CONTENT_LENGTH = " . $env['CONTENT_LENGTH'] . " @@ -2657,7 +2664,8 @@ COMMAND $cmd if ($test->hasSection('XFAIL')) { $warn = true; $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; $info = " (warn: XLEAK section but test passes)"; } else { @@ -2694,7 +2702,8 @@ COMMAND $cmd if ($test->hasSection('XFAIL')) { $restype[] = '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'; $info = ' XLEAK REASON: ' . rtrim($test->getSection('XLEAK')); } else {