Fix phpdbg over-read watching an element of a packed array#22756
Open
iliaal wants to merge 1 commit into
Open
Conversation
phpdbg watches every array element as a Bucket, but a packed array stores bare zvals, so reading Bucket.h/.key reads the adjacent element. Writing a neighbouring element then trips the watchpoint with the value unchanged: a phantom break on 32-bit, and a crash on 32-bit Windows (phpGH-22480 dropped watch_006's xfail, which exposed it). When the watched element lives in a packed array, detect relocation by re-resolving it in its parent and compare only the zval value.
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.
Packed arrays store bare zvals, but phpdbg watches every array element as a
Bucketand readsBucket.h/.keyin its relocation check, over-reading the neighbouring element. A sibling write then fires a phantom watchpoint, which crashed on 32-bit Windows (WINDOWS_X86_NTSin the nightly) once GH-22480 un-xfailedwatch_006. For a packed parent, relocation is now detected by re-resolving the element and only the zval value is compared.Note:
watch_005still carries aPHP_INT_SIZE == 4xfail with the same "flaws in the implementation of watchpoints" wording, but on a different path (string/reference indirection, not packed buckets). It likely hides a related but distinct 32-bit flaw masked by that skip; this change does not touch it, so it stays skipped.