Skip to content

Commit b93d971

Browse files
committed
Add zend_alloc XLEAK support
In the future we may want to use a different exit code to warn for tests that didn't leak.
1 parent 50f58c8 commit b93d971

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

Zend/zend_alloc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2290,7 +2290,11 @@ void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent)
22902290

22912291
#if ZEND_DEBUG
22922292
if (!silent) {
2293-
zend_mm_check_leaks(heap);
2293+
char *tmp;
2294+
tmp = getenv("ZEND_ALLOC_PRINT_LEAKS");
2295+
if (!tmp || ZEND_ATOL(tmp)) {
2296+
zend_mm_check_leaks(heap);
2297+
}
22942298
}
22952299
#endif
22962300

ext/gettext/tests/bug53251.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Bug #53251 (bindtextdomain with null dir doesn't return old value)
44
gettext
55
--SKIPIF--
66
<?php
7-
if (getenv('SKIP_REPEAT')) die('skip gettext leaks global state across requests');
7+
if (getenv('SKIP_REPEAT')) die('xleak gettext leaks global state across requests');
88
?>
99
--FILE--
1010
<?php

ext/pcntl/tests/bug81577_3.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Bug #81577: (Exceptions in interrupt handlers: cleanup_live_vars)
33
--EXTENSIONS--
44
pcntl
55
posix
6-
--XFAIL--
6+
--XLEAK--
77
leaks are not fixed yet
88
--FILE--
99
<?php

run-tests.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2464,8 +2464,11 @@ function run_test(string $php, $file, array $env): string
24642464
$cmd = $valgrind->wrapCommand($cmd, $memcheck_filename, strpos($test_file, "pcre") !== false);
24652465
}
24662466

2467-
if ($test->hasSection('XLEAK') && isset($env['SKIP_ASAN'])) {
2468-
$env['LSAN_OPTIONS'] = 'detect_leaks=0';
2467+
if ($test->hasSection('XLEAK')) {
2468+
$env['ZEND_ALLOC_PRINT_LEAKS'] = '0';
2469+
if (isset($env['SKIP_ASAN'])) {
2470+
$env['LSAN_OPTIONS'] = 'detect_leaks=0';
2471+
}
24692472
}
24702473

24712474
if ($DETAILED) {
@@ -2664,7 +2667,7 @@ function run_test(string $php, $file, array $env): string
26642667
if ($test->hasSection('XFAIL')) {
26652668
$warn = true;
26662669
$info = " (warn: XFAIL section but test passes)";
2667-
} elseif ($test->hasSection('XLEAK') && !isset($env['SKIP_ASAN'])) {
2670+
} elseif ($test->hasSection('XLEAK') && $valgrind) {
26682671
// XLEAK with ASAN completely disables LSAN so the test is expected to pass
26692672
$warn = true;
26702673
$info = " (warn: XLEAK section but test passes)";
@@ -2702,7 +2705,7 @@ function run_test(string $php, $file, array $env): string
27022705
if ($test->hasSection('XFAIL')) {
27032706
$restype[] = 'XFAIL';
27042707
$info = ' XFAIL REASON: ' . rtrim($test->getSection('XFAIL'));
2705-
} elseif ($test->hasSection('XLEAK') && !isset($env['SKIP_ASAN'])) {
2708+
} elseif ($test->hasSection('XLEAK') && $valgrind) {
27062709
// XLEAK with ASAN completely disables LSAN so the test is expected to pass
27072710
$restype[] = 'XLEAK';
27082711
$info = ' XLEAK REASON: ' . rtrim($test->getSection('XLEAK'));

0 commit comments

Comments
 (0)