Skip to content

sapi/phpdbg: Fix btree cleanup skipping out-of-line branches - #25835

Open
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/aph-phpdbg-btree-cleanup-double-free-brpd-84-work
Open

iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/aph-phpdbg-btree-cleanup-double-free-brpd-84-work

Conversation

@iliaal

@iliaal iliaal commented Nov 27, 2026

Copy link
Copy Markdown
Member

When a phpdbg watchpoint tree still holds entries at shutdown, phpdbg_btree_clean_recursive() never steps to the next node of a contiguously allocated chain and only looks at the first node's sibling. Branches hanging off deeper nodes leak, and for keys that differ in the top bit the first node's sibling is freed once per remaining level. There is no test: on a normal exit the trees are already empty, and the double free needs keys that differ in bit 63, which no x86-64 user-space pointer does.

phpdbg_btree_clean_recursive() never advanced past the first node of a
contiguously allocated chain, so it only ever looked at that node's
sibling. Siblings hanging off deeper nodes were leaked whenever a
watchpoint tree still held entries at request shutdown, and a sibling on
the first node, i.e. keys differing in the top bit, was freed once per
remaining level. Step to the next node of the chain on every level.

@jorgsowa jorgsowa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see branch name points to 8.4, but this PR targets master. It may target 8.4. Change looks good to me.

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.

2 participants