fix GH-20469: inheritance cache lookup with nested autoloading #22221
Open
morrisonlevi wants to merge 1 commit into
Open
fix GH-20469: inheritance cache lookup with nested autoloading #22221morrisonlevi wants to merge 1 commit into
morrisonlevi wants to merge 1 commit into
Conversation
unlinked_instanceof() may see a linked starting class while an ancestor in its parent chain is still unlinked. Keep the guarded traversal instead of delegating to instanceof_function(), which assumes resolved parent pointers throughout the chain. See ext/opcache/tests/gh20469.phpt.
Member
|
There may be a deeper issue as I think that we are supposed to mark classes as linked only when the fully hierarchy is linked. Especially, we shouldn't cache such class in the inheritance cache. We can observe that linking is not complete as methods from grand parent of diff --git a/ext/opcache/tests/gh20469.phpt b/ext/opcache/tests/gh20469.phpt
index 1cd826c177e..dfab60c79be 100644
--- a/ext/opcache/tests/gh20469.phpt
+++ b/ext/opcache/tests/gh20469.phpt
@@ -33,6 +33,9 @@
<?php
require __DIR__ . '/autoload.php';
echo \APP\ParentBeingLinked::SOME_CONSTANT;
+$i = new \APP\ChildOfParentBeingLinked();
+var_dump($i->test());
PHP);
file_put_contents($dir . '/classes/RootForTraitReturn.php', <<<'PHP'
@@ -44,6 +47,7 @@ class RootForTraitReturn
function createResult(): BaseCovariantReturn
{
}
+ function test() {}
}
PHP);The call results in |
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.
Crashes commonly manifest in
instanceof_function_slow.unlinked_instanceof()may see a linked starting class while an ancestor in its parent chain is still unlinked. Keep the guarded traversal instead of delegating toinstanceof_function(), which assumes resolved parent pointers throughout the chain.See the
ext/opcache/tests/gh20469.phpttest I added.This has been a bug since PHP 8.1, I can reproduce it with the dockerhub
php:8.1-cliimage. I'm targeting PHP 8.4 for the fix, as it's the oldest version in active support.