GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||
GeezerVison is showing github.com — Fix GH-23089: stack overflow in array_merge_recursive() with deep arrays by lazerg · Pull Request #23091 · php/php-src Conversation
|
|
Hi @devnexen, just checking if you have had a chance to look at this crash fix. Happy to make any changes needed. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Probably I need to create seperate PR for that? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yes, that is not a blocker for this PR, just something I realized while looking at this PR. I could have been more clear, sorry about that. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
array_replace_recursive() already got this same stack check in af1abdf (#23124, fixing GH-23113), merged on 2026-08-10. So it should already be covered on master. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
This exposes a memory leak. When ret = php_array_merge_recursive(Z_ARRVAL_P(dest_zval), Z_ARRVAL_P(src_zval)); if (thash) { GC_TRY_UNPROTECT_RECURSION(thash); } if (!ret) { return 0; } This is missing Test case: --TEST-- GH-23089 (Memory leak in array_merge_recursive on stack overflow with object) --SKIPIF-- <?php if (ini_get('zend.max_allowed_stack_size') === false) { die('skip No stack limit support'); } if (getenv('SKIP_ASAN')) { die('skip ASAN needs different stack limit setting due to more stack space usage'); } ?> --INI-- zend.max_allowed_stack_size=256K --FILE-- <?php $obj = new stdClass(); $deep = []; for ($i = 0; $i < 30000; $i++) { $deep = ['k' => $deep]; } $obj->val = $deep; $a = ['obj' => $obj]; try { array_merge_recursive($a, $a); } catch (Throwable $e) { echo $e::class, ": ", $e->getMessage(), "\n"; } echo "done\n"; ?> --EXPECTF-- Error: Maximum call stack size of %d bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? done This outputs things like: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Confirmed. I built PHP with I added The leaks are gone now, and ext/standard plus Zend give 8033 passed, 0 failed. I also added your test case as Commit: c425d88 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks. This looks good to me! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Closing this due to no activity. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.