Skip to content

Fix phpdbg over-read watching an element of a packed array#22756

Open
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/phpdbg-watch-packed-bucket-overread
Open

Fix phpdbg over-read watching an element of a packed array#22756
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:fix/phpdbg-watch-packed-bucket-overread

Conversation

@iliaal

@iliaal iliaal commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Packed arrays store bare zvals, but phpdbg watches every array element as a Bucket and reads Bucket.h/.key in its relocation check, over-reading the neighbouring element. A sibling write then fires a phantom watchpoint, which crashed on 32-bit Windows (WINDOWS_X86_NTS in the nightly) once GH-22480 un-xfailed watch_006. For a packed parent, relocation is now detected by re-resolving the element and only the zval value is compared.

Note: watch_005 still carries a PHP_INT_SIZE == 4 xfail 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.

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.
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.

1 participant