Repository navigation
Fix GH-25756: Do not fold IS_VAR QM_ASSIGN into ZEND_RETURN - #25781
Closed
prateekbhujel wants to merge 1 commit into
Closed
prateekbhujel wants to merge 1 commit into
prateekbhujel wants to merge 1 commit into
Conversation
Since the VAR|TMP overhaul (phpGH-20628, 6173a9a), ZEND_RETURN only handles CONST|TMP|CV operands, and by-reference assignments (such as `return $a = &$b`) rely on ZEND_QM_ASSIGN to unwrap the IS_VAR reference into an IS_TMP_VAR. The block pass folded `T = QM_ASSIGN(X); RETURN(T)` into `RETURN(X)` without checking `src->op1_type != IS_VAR` (unlike the ZEND_JMPZ/ZEND_JMPZ_EX folds in the same pass), emitting an invalid `ZEND_RETURN` with an `IS_VAR` operand ("Invalid opcode 62/4/0"). Closes phpGH-25756
Contributor
|
The same solution as in https://github.com/iliaal/php-src/pull/478/files CC: @iliaal |
Contributor
Author
|
My bad, missed the cross-referenced PR on iliaal#478. Closing in favor of @iliaal's fix. |
Contributor
|
No problem, if you see that someone is already assigned to the issue, then the person likely already started work on it. |
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.
Since the VAR|TMP overhaul (GH-20628,
6173a9a1098),ZEND_RETURNonly handlesCONST|TMP|CVoperands, and by-reference assignments (e.g.return $a = &$b;, arrow functions,matcharms) emitZEND_QM_ASSIGNto unwrap theIS_VARreference into anIS_TMP_VAR.In
Zend/Optimizer/block_pass.c, theZEND_RETURNoptimization foldedT = QM_ASSIGN(X); RETURN(T)intoRETURN(X)without checkingsrc->op1_type != IS_VAR(unlike theZEND_JMPZ/ZEND_JMPNZandZEND_JMPZ_EX/ZEND_JMPNZ_EXfolds in the same pass), producingZEND_RETURNwith anIS_VARoperand (Fatal error: Invalid opcode 62/4/0).Audited all other
COPY_NODE/ZEND_QM_ASSIGNfolds inZend/Optimizer/block_pass.cagainst the handlers changed in GH-20628;ZEND_RETURNis the only missingsrc->op1_type != IS_VARguard.Closes GH-25756.