Skip to content

Add ASAN XLEAK support #10996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ jobs:
matrix:
include:
- debug: true
zts: false
- debug: false
zts: true
name: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
runs-on: ubuntu-22.04
Expand All @@ -68,6 +66,9 @@ jobs:
configurationParameters: >-
--${{ matrix.debug && 'enable' || 'disable' }}-debug
--${{ matrix.zts && 'enable' || 'disable' }}-zts
--enable-address-sanitizer
--enable-undefined-sanitizer
CFLAGS="-DZEND_TRACK_ARENA_ALLOC"
- name: make
run: make -j$(/usr/bin/nproc) >/dev/null
- name: make install
Expand All @@ -78,6 +79,7 @@ jobs:
uses: ./.github/actions/test-linux
with:
testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}
runTestsParameters: --asan
- name: Test Tracing JIT
uses: ./.github/actions/test-linux
with:
Expand All @@ -86,6 +88,7 @@ jobs:
-d zend_extension=opcache.so
-d opcache.enable_cli=1
-d opcache.jit_buffer_size=16M
--asan
- name: Verify generated files are up to date
uses: ./.github/actions/verify-generated-files
LINUX_X32:
Expand Down
2 changes: 1 addition & 1 deletion ext/enchant/tests/dict_quick_check.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ marcosptf - <[email protected]>
enchant
--SKIPIF--
<?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_array(enchant_broker_list_dicts(enchant_broker_init()))) {die("skip, no dictionary installed on this machine! \n");}

Expand Down
2 changes: 1 addition & 1 deletion ext/ffi/tests/bug79576.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bug #79576 ("TYPE *" shows unhelpful message when type is not defined)
ffi
--SKIPIF--
<?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--
<?php
Expand Down
2 changes: 1 addition & 1 deletion ext/imap/tests/imap_getsubscribed_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ imap
--SKIPIF--
<?php
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--
defaultmailbox
Expand Down
2 changes: 1 addition & 1 deletion ext/imap/tests/imap_lsub_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ imap
--SKIPIF--
<?php
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--
defaultmailbox
Expand Down
2 changes: 1 addition & 1 deletion ext/imap/tests/imap_open_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ imap
--SKIPIF--
<?php
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--
<?php
Expand Down
2 changes: 1 addition & 1 deletion ext/oci8/tests/privileged_connect1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ privileged connect tests
oci8
--SKIPIF--
<?php
if (getenv('SKIP_ASAN')) die('skip leaks memory under asan');
if (getenv('SKIP_ASAN')) die('xleak leaks memory under asan');
?>
--INI--
oci8.privileged_connect=1
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/tests/gh9259_003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bug GH-9259 003 (Setting opcache.interned_strings_buffer to a very high value le
opcache
--SKIPIF--
<?php
if (getenv('SKIP_ASAN')) die('xfail Leaks memory with ASAN');
if (getenv('SKIP_ASAN')) die('xleak Leaks memory with ASAN');
?>
--INI--
opcache.interned_strings_buffer=500
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/tests/log_verbosity_bug.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ opcache.log_verbosity_level=-1
opcache
--SKIPIF--
<?php
if (getenv('SKIP_ASAN')) die('xfail Startup failure leak');
if (getenv('SKIP_ASAN')) die('xleak Startup failure leak');
?>
--FILE--
<?php
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/tests/preload_006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ opcache
--SKIPIF--
<?php
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--
<?php
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/tests/preload_parse_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ opcache
--SKIPIF--
<?php
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--
OK
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo_oci/tests/pecl_bug_6364.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pdo
pdo_oci
--SKIPIF--
<?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');
PDOTest::skip();
?>
Expand Down
2 changes: 1 addition & 1 deletion ext/posix/tests/posix_getgrgid_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Test posix_getgrgid() function : error conditions
posix
--SKIPIF--
<?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--
<?php
Expand Down
2 changes: 1 addition & 1 deletion ext/posix/tests/posix_getpwuid_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Test posix_getpwuid() function : error conditions
posix
--SKIPIF--
<?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--
<?php
Expand Down
2 changes: 1 addition & 1 deletion ext/pspell/tests/005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pspell
--SKIPIF--
<?php
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--
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Francesco Fullone [email protected]
--INI--
magic_quotes_gpc=1
--SKIPIF--
<?php if (getenv('SKIP_ASAN')) die('xfail Startup failure leak'); ?>
<?php if (getenv('SKIP_ASAN')) die('xleak Startup failure leak'); ?>
--FILE--
<?php
echo "*** Test by calling method or function with deprecated option ***\n";
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/streams/bug46024.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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");
// 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.
if (getenv('SKIP_ASAN')) die("skip Test may leak");
if (getenv('SKIP_ASAN')) die("xleak Test may leak");
?>
--FILE--
<?php
Expand Down
13 changes: 11 additions & 2 deletions run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -2207,6 +2207,9 @@ function run_test(string $php, $file, array $env): string
} elseif (!strncasecmp('xfail', $output, 5)) {
// Pretend we have an XFAIL section
$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 !== '') {
show_result("BORK", $output, $tested_file, 'reason: invalid output from SKIPIF', $temp_filenames);
$PHP_FAILED_TESTS['BORKED'][] = [
Expand Down Expand Up @@ -2461,6 +2464,10 @@ function run_test(string $php, $file, array $env): string
$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'] . "
Expand Down Expand Up @@ -2657,7 +2664,8 @@ function run_test(string $php, $file, array $env): string
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 {
Expand Down Expand Up @@ -2694,7 +2702,8 @@ function run_test(string $php, $file, array $env): string
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 {
Expand Down