Repository navigation
Conversation
Keep the dereferencing QM_ASSIGN when its source is IS_VAR. ZEND_RETURN only accepts CONST, TMP, and CV, so folding the assignment into the return can produce an invalid opcode for by-reference assignments or list destructuring. Fixes phpGH-25756
iliaal
force-pushed
the
fix/gh-25756-return-assign-ref-opcache
branch
from
November 26, 2026 23:27
aea9580 to
85a561c
Compare
Owner
Author
|
Submitted upstream as php#25814. |
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.
In
Zend/Optimizer/block_pass.c,zend_optimize_block()eliminates aZEND_QM_ASSIGNfeedingZEND_RETURNby copyingsrc->op1intoZEND_RETURNwithout checkingsrc->op1_type.Since phpGH-20628 (
6173a9a1098),ZEND_RETURN(opcode 62) only hasCONST|TMP|CVhandlers and noVARhandler. By-reference assignments ($a = &$b,$obj->p = &$b,$arr[0] = &$b,C::$p = &$b) and by-reference list destructuring ([&$a] = $arr) in a read context emit aZEND_QM_ASSIGNdereference wrapper to convertIS_VARtoIS_TMP_VAR. Dropping thatZEND_QM_ASSIGNleavesZEND_RETURNwithIS_VAR(type 4) and fails at runtime withFatal error: Invalid opcode 62/4/0..Guard the
ZEND_RETURNsubstitution withsrc->op1_type != IS_VAR, as done forZEND_JMPZ/ZEND_JMPNZandZEND_JMPZ_EX/ZEND_JMPNZ_EXin6441f89857b(phpGH-21691).Fixes phpGH-25756