Fix IS_IDENTICAL_EMPTY_ARRAY specialization for an IS_CONST op1 - #23545
Open
Mrmaxmeier wants to merge 1 commit into
Open
Fix IS_IDENTICAL_EMPTY_ARRAY specialization for an IS_CONST op1#23545Mrmaxmeier wants to merge 1 commit into
Mrmaxmeier wants to merge 1 commit into
Conversation
The ZEND_IS_IDENTICAL_EMPTY_ARRAY / ZEND_IS_NOT_IDENTICAL_EMPTY_ARRAY
specializations are declared as TMPVARCV, CONST, but their selection condition
only looked at op2. The other specializations of these opcodes bail out for a
CONST/CONST operand pair, this one did not, so an IS_CONST op1 selected a
handler that cannot read it and _get_zval_ptr_tmpvarcv() asserted:
if (A::class->p === []) {
}
Type inference proves the property fetch to be null and substitutes the
constant into op1, but the comparison itself is not folded, which leaves
ZEND_IS_IDENTICAL with two IS_CONST operands.
Assisted-By: Claude Opus 5 <noreply@anthropic.com>
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.
Hi,
we ran into an assertion failure in the VM with the
fuzzer-function-jitfuzzing target:On a debug build this aborts in
_get_zval_ptr_tmpvarcv().ZEND_IS_IDENTICAL_EMPTY_ARRAYis new in 8.5, so this does not affect 8.4.Assertion backtrace for reproducer
The
ZEND_IS_IDENTICAL_EMPTY_ARRAY/ZEND_IS_NOT_IDENTICAL_EMPTY_ARRAYspecializations are declared for the operand pairTMPVARCV, CONST:but the condition that selects them only ever looked at
op2. The other specializations of these opcodes bail out for aCONST/CONSToperand pair, this one did not. So anIS_CONSTop1 still selected a handler that reads its op1 through_get_zval_ptr_tmpvarcv(), which cannot read a literal and asserts.Getting there needs the optimizer: type inference proves the property fetch on the
A::classstring to be null and substitutes the constant into op1, but the comparison itself is not folded, which leaves aZEND_IS_IDENTICALwith twoIS_CONSToperands for the specializer to look at.The fix adds the missing
op->op1_type != IS_CONSTto the selection condition of both handlers, which is what the sibling specializations already do.Thanks!
Found by the CISPA Fandango team while triaging findings in oss-fuzz harnesses.