Skip to content

Fix GH-16811: Crash in zend_test observer on runtime observe_function_names change#21635

Open
iliaal wants to merge 1 commit intophp:masterfrom
iliaal:fix/gh-16811-observer-ini-set-crash
Open

Fix GH-16811: Crash in zend_test observer on runtime observe_function_names change#21635
iliaal wants to merge 1 commit intophp:masterfrom
iliaal:fix/gh-16811-observer-ini-set-crash

Conversation

@iliaal
Copy link
Copy Markdown
Contributor

@iliaal iliaal commented Apr 4, 2026

zend_test_observer_OnUpdateCommaList crashes when ini_set changes observe_function_names at runtime. Two paths:

  1. Function exists in the function table but was never called. RUN_TIME_CACHE is NULL, so ZEND_OBSERVER_DATA null-derefs in zend_observer_remove_handler.

  2. observe_all=1 already installed the handler at first call. OnUpdateCommaList adds the same handler again, finds no free slot, hits ZEND_UNREACHABLE().

Fix: guard remove/add with runtime cache checks, and remove existing handlers before re-adding to prevent duplicates.

Fixes #16811

…ion_names change

OnUpdateCommaList called zend_observer_remove/add_begin_handler without
checking whether observer data was initialized. This null-dereferenced
when the function had never been called (no runtime cache), and hit
ZEND_UNREACHABLE() when observe_all had already installed the same
handler.

Guard both the remove and add blocks with runtime cache checks. Remove
existing handlers before re-adding to prevent slot overflow from
duplicates.

Closes phpGH-16811
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.

Segmentation fault in zend observer

1 participant