Fix GH-16811: Crash in zend_test observer on runtime observe_function_names change#21635
Open
iliaal wants to merge 1 commit intophp:masterfrom
Open
Fix GH-16811: Crash in zend_test observer on runtime observe_function_names change#21635iliaal wants to merge 1 commit intophp:masterfrom
iliaal wants to merge 1 commit intophp:masterfrom
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
zend_test_observer_OnUpdateCommaListcrashes whenini_setchangesobserve_function_namesat runtime. Two paths:Function exists in the function table but was never called.
RUN_TIME_CACHEis NULL, soZEND_OBSERVER_DATAnull-derefs inzend_observer_remove_handler.observe_all=1already installed the handler at first call.OnUpdateCommaListadds the same handler again, finds no free slot, hitsZEND_UNREACHABLE().Fix: guard remove/add with runtime cache checks, and remove existing handlers before re-adding to prevent duplicates.
Fixes #16811