Repository navigation
lexbor: Fix the allocation and move sizes of lexbor_array_obj_t - #25431
Open
nicolas-grekas wants to merge 1 commit into
Open
nicolas-grekas wants to merge 1 commit into
nicolas-grekas wants to merge 1 commit into
Conversation
lexbor_array_obj_init() and lexbor_array_obj_expand() allocated 8 times the memory they need on 64-bit platforms, and lexbor_array_obj_delete() moved 8 times the bytes of the remaining entries. This is patch 0025, merged upstream as lexbor/lexbor@f4cbbcd. ext/dom uses such an array as its work list when it converts the parsed tree to libxml2, so gh25118.phpt needs a lower memory_limit to still fail during that conversion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split from #23949.
lexbor_array_obj_tallocates 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>'withDom\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.phptrelied on the oversized work list to reach its 32MBmemory_limitduring 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.