Skip to content

ext/standard: Detach shutdown callbacks before cleanup - #25975

Open
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/gh-25920-shutdown-table
Open

iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/gh-25920-shutdown-table

Conversation

@iliaal

@iliaal iliaal commented Nov 30, 2026

Copy link
Copy Markdown
Member

A destructor that calls register_shutdown_function() while php_free_shutdown_functions() destroys the shutdown table can resize the bucket array that zend_hash_destroy() is still walking, a use-after-free. Detach the table from BG(user_shutdown_function_names) before destroying it, and drain any table a destructor creates meanwhile so late callback arguments are still released. Targets master because the trigger needs a reentrant userland destructor.

Fixes GH-25920

Both userland and extension registration can reach the shutdown table while
zend_hash_destroy() walks it, invalidating cached bucket pointers. Detach
the table before destruction and drain any tables created by destructors.

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

1 participant