Skip to content

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

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

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

Conversation

@iliaal

@iliaal iliaal commented Jul 15, 2026

Copy link
Copy Markdown
Owner

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 phpGH-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.
@iliaal

iliaal commented Jul 15, 2026

Copy link
Copy Markdown
Owner Author

Submitted upstream as php#22756.

@iliaal iliaal closed this Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant