Skip to content

Change YIELD/YIELD_FROM to do not increment opline #15328

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

Conversation

arnaud-lb
Copy link
Member

@arnaud-lb arnaud-lb commented Aug 10, 2024

This is an alternative of #15275

YIELD and YIELD_FROM increment opline before returning, but in most places we need the opline to point to the YIELD and YIELD_FROM.

Here I change YIELD/YIELD_FROM to not increment opline. This simplifies the code a fixes a few crashes.

* generator is being force-closed (opline points to the start of a finally
* block).
*/
if (EXPECTED(generator->execute_data->opline->opcode != ZEND_HANDLE_EXCEPTION
Copy link
Member

Choose a reason for hiding this comment

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

The check for ZEND_HANDLE_EXCEPTION is not really necessary as EG(exception_op) has a couple ops at once. Only thing needing check is the force close.

Though, for that case, you can just decrement the opline in zend_generator_dtor_storage before calling this function, eliminating the need for the branch altogether.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice!

@bwoebi
Copy link
Member

bwoebi commented Aug 10, 2024

This changes the ReflectionGenerator::getExecutingLine() output, but I believe that's a good thing.
I like this approach very much!

@arnaud-lb
Copy link
Member Author

This targets master, but do you think we can target 8.2? This may be a breaking change for extensions

@bwoebi
Copy link
Member

bwoebi commented Aug 10, 2024

No, you should not target 8.2 I think. I suspect you need to merge the other PR for 8.2, then use this one on master.

@arnaud-lb arnaud-lb force-pushed the delegate-generator-exception-crash-2-master branch from 8a7dcbd to 84ea7a6 Compare August 10, 2024 14:00
@arnaud-lb arnaud-lb closed this in c02c1d4 Aug 10, 2024
nicolas-grekas added a commit to symfony/symfony that referenced this pull request Aug 12, 2024
…ndre-daubois)

This PR was merged into the 5.4 branch.

Discussion
----------

[VarDumper] Fix generator dump format for PHP 8.4

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | -
| License       | MIT

Generator dump format likely changed because of php/php-src#15328. I propose to update the test dedicated to dumping generators in PHP >= 8.4.

cc `@xabbuh`

Commits
-------

6bb252d [VarDumper] Fix generator dump format for PHP 8.4
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.

2 participants