From f3e87e2a6dc0ef4aaa587b6975fdd85729c30b23 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Tue, 22 Oct 2024 12:38:42 +0200 Subject: [PATCH] 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 --- ext/json/tests/gh15168.phpt | 4 ++++ ext/standard/tests/serialize/gh15169.phpt | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/ext/json/tests/gh15168.phpt b/ext/json/tests/gh15168.phpt index 9b674d6b4ac..66000e5b90e 100644 --- a/ext/json/tests/gh15168.phpt +++ b/ext/json/tests/gh15168.phpt @@ -31,6 +31,10 @@ var_dump(json_encode($firstNode, depth: 500000)); var_dump(json_last_error()); var_dump(json_last_error_msg()); +while ($next = $firstNode->next) { + $firstNode->next = $next->next; +} + ?> --EXPECT-- bool(false) diff --git a/ext/standard/tests/serialize/gh15169.phpt b/ext/standard/tests/serialize/gh15169.phpt index 677982141ab..7e76b0228c7 100644 --- a/ext/standard/tests/serialize/gh15169.phpt +++ b/ext/standard/tests/serialize/gh15169.phpt @@ -30,6 +30,11 @@ try { } catch (Error $e) { echo $e->getMessage(), "\n"; } + +while ($next = $firstNode->next) { + $firstNode->next = $next->next; +} + ?> --EXPECT-- Maximum call stack size reached. Infinite recursion?