Skip to content

Commit f3e87e2

Browse files
committed
Fix tests: Prevent stack overflow during dtor
On s390x the stack is smaller and/or the object dtor code uses more stack, which causes the destruction of deeply nested objects to crash in these tests. Here I ensure that objects are released one by one at the end of the tests to avoid recursive dtor. Closes GH-16561 Fixes GH-16528
1 parent 6d6afd9 commit f3e87e2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

ext/json/tests/gh15168.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ var_dump(json_encode($firstNode, depth: 500000));
3131
var_dump(json_last_error());
3232
var_dump(json_last_error_msg());
3333

34+
while ($next = $firstNode->next) {
35+
$firstNode->next = $next->next;
36+
}
37+
3438
?>
3539
--EXPECT--
3640
bool(false)

ext/standard/tests/serialize/gh15169.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ try {
3030
} catch (Error $e) {
3131
echo $e->getMessage(), "\n";
3232
}
33+
34+
while ($next = $firstNode->next) {
35+
$firstNode->next = $next->next;
36+
}
37+
3338
?>
3439
--EXPECT--
3540
Maximum call stack size reached. Infinite recursion?

0 commit comments

Comments
 (0)