[DOM] Root and clear DOMXPath callback node_list - #299
Open
iliaal wants to merge 1 commit into
Open
Conversation
Node proxies moved into the XPath callback registry's node_list stayed referenced until object destruction, pinning callback arguments/results for the whole lifetime of the DOMXPath object, and the collector could not see that ownership edge because node_list was absent from get_gc(). Trace node_list entries in php_dom_xpath_callbacks_get_gc() (and include it in the gc-handler fast-path condition) and clear node_list at the end of each evaluation once results are materialized. Siblings audited: all php_dom_xpath_callbacks_clean_node_list() call sites (dtor plus both new eval paths) and the single dom_xpath_get_gc() handler wiring.
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.
Nodes moved into the DOMXPath callback registry's node_list (php:function arguments and returned nodes) were only released when the DOMXPath object was destroyed, so long-lived XPath objects pinned them forever, and get_gc() could not see the ownership edge because node_list entries were not traced. This traces node_list in php_dom_xpath_callbacks_get_gc(), includes it in the gc fast-path condition, and clears node_list at the end of every evaluation once results are materialized. A new phpt shows callback argument proxies being released after evaluation, including a cyclic case.