Skip to content

Fix incorrect comparison in block optimization pass #10329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

nielsdos
Copy link
Member

We're in the case of ZEND_JMPZ_EX or ZEND_JMPNZ_EX. The opcode gets overwritten and only after the overwriting gets checked if we're in a JMPZ or JMPNZ case. This results in a wrong optimization.

Unfortunately, I couldn't find an easy way to write a test because zend_compile.c already checks for the constant case. Still, it could be that this code can still be reached because of a combination of optimizations.

Note that I found this issue using a static analyser which reported this always-false check.

We're in the case of ZEND_JMPZ_EX or ZEND_JMPNZ_EX. The opcode gets
overwritten and only after the overwriting gets checked if we're in a
JMPZ or JMPNZ case. This results in a wrong optimization.
@devnexen
Copy link
Member

Jesus always so productive :-)

@devnexen devnexen requested a review from dstogov January 15, 2023 14:46
@Girgias Girgias requested a review from arnaud-lb January 15, 2023 15:01
Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

Nice catch! Thank you!

@dstogov
Copy link
Member

dstogov commented Jan 16, 2023

@nielsdos thanks for catching this.

@devnexen devnexen closed this in dfe9c2a Jan 16, 2023
@devnexen
Copy link
Member

Merged via dfe9c2af1. Thanks

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