Skip to content

dom: report the DOMXPath callback node list to the cycle collector - #23596

Open
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:promote/dom-xpath-node-list-gc
Open

dom: report the DOMXPath callback node list to the cycle collector#23596
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:promote/dom-xpath-node-list-gc

Conversation

@iliaal

@iliaal iliaal commented Sep 6, 2026

Copy link
Copy Markdown
Member

php_dom_xpath_callbacks_get_gc() traced php_ns and namespaces but not node_list, which holds the nodes passed to and returned from php:function callbacks. A cycle from a DOMXPath through node_list to a node and back to the same DOMXPath was invisible to the collector, so it was never freed.

node_list is still cleared at object destruction rather than at the end of each evaluation. Clearing it eagerly is not safe, because a callback can run a nested query()/evaluate() on the same object and the inner call would free wrappers the outer evaluation is still using.

php_dom_xpath_callbacks_get_gc() traced php_ns and namespaces but not
node_list, which holds the nodes handed to and returned from php:function
callbacks. A cycle running DOMXPath to node_list to node and back to the
same DOMXPath was therefore invisible to the collector and never freed.

Closes phpGH-23596
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant