Skip to content

Fix GH-25253: JIT reads parent of an unlinked class - #25259

Closed
lazerg wants to merge 1 commit into
php:PHP-8.5from
lazerg:fix/gh-25253-jit-unlinked-parent
Closed

lazerg wants to merge 1 commit into
php:PHP-8.5from
lazerg:fix/gh-25253-jit-unlinked-parent

Conversation

@lazerg

@lazerg lazerg commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

zend_get_known_class() follows ce->parent for parent:: without checking ZEND_ACC_LINKED, so for a class whose parent lives in another file it reads parent_name as a class entry. The check after it rarely saves us: the persisted string has refcount 2, so type reads as ZEND_USER_CLASS, and once the interned strings buffer is full the string is copied into the script's own shm, where the word at info.user.filename can be this script's filename. Then zend_hash_find() runs on garbage. The fix checks the flag first, like the optimizer already does. The test uses opcache.interned_strings_buffer=0 to get the same layout and segfaults without the fix.

Fixes #25253

Co-authored-by: mlenarciak <39970740+mlenarciak@users.noreply.github.com>

@iliaal iliaal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LamentXU123 LamentXU123 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understandable edge cases ig. Before I click the merge button I want to hear from Nora.

@LamentXU123
LamentXU123 requested a review from ndossche November 8, 2026 13:47

@ndossche ndossche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah normally in these places for the JIT/Optimizer we check for the linked flag, but apparently this was forgotten here

LamentXU123 added a commit that referenced this pull request Nov 8, 2026
* PHP-8.6:
  Fix GH-25253: JIT reads parent of an unlinked class (#25259)
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-php__php-src that referenced this pull request Nov 8, 2026
* PHP-8.5:
  Fix phpGH-25253: JIT reads parent of an unlinked class (php#25259)
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.

4 participants