Skip to content

[DOM] Root and clear DOMXPath callback node_list - #299

Open
iliaal wants to merge 1 commit into
masterfrom
fix/dom-xpath-node-list-gc-master
Open

[DOM] Root and clear DOMXPath callback node_list#299
iliaal wants to merge 1 commit into
masterfrom
fix/dom-xpath-node-list-gc-master

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant