[php-src] PR #25431: lexbor: Fix the allocation and move sizes of lexbor_array_obj_t
| From: | nicolas-grekas | Date: | Thu, 12 Nov 2026 17:56:19 +0000 |
| Subject: | [php-src] PR #25431: lexbor: Fix the allocation and move sizes of lexbor_array_obj_t | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40595@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25431
Author: nicolas-grekas
Split from #23949.
lexbor_array_obj_t allocates 8 times the memory it uses. ext/dom uses such an array as
its work list when it converts the parsed tree to libxml2. The waste grows with the number of
sibling nodes. Parsing '<main>' . str_repeat('<i></i>',
100000) . '</main>' with Dom\HTMLDocument::createFromString()
now peaks at 25.6MB instead of 52.4MB.
The fix is lexbor/lexbor@f4cbbcd, already merged upstream. This PR adds it as patch 0025.
gh25118.phpt relied on the oversized work list to reach its 32MB
memory_limit during the conversion. I lowered the limit to 26M so that the test still
fails there. It's now skipped when the Zend allocator is disabled, because the limit is then
reached at another point. The test still crashes when the fix for GH-25118 is reverted. @devnexen
please tell me if you prefer another way.