-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix generator memory leaks when interrupted during argument evaluation #9756
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
@@ -3841,6 +3841,138 @@ static zend_always_inline zend_generator *zend_get_running_generator(EXECUTE_DAT | |||
} | |||
/* }}} */ | |||
|
|||
ZEND_API void zend_unfinished_calls_gc(zend_execute_data *execute_data, zend_execute_data *call, uint32_t op_num, zend_get_gc_buffer *buf) /* {{{ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This duplicates cleanup_unfinished_calls(). I will look into ways to factor this out in an other PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is reused in #9810
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to simplify cleanup_unfinished_calls() in a way that it calls this function with a buffer, then frees all zvals on that buffer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try this
<?php | ||
if (version_compare(PHP_VERSION, '8.1', '<')) { die('skip Broken on PHP < 8.1'); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8.0 calls D::__destructor
: https://3v4l.org/32Ku7
8.1 does not because the constructor has not been called
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first this looks terrible, but I don't see another solution and approve.
Actually, our "backup" GC started to walk over generators stacks, that made it similar to classic mark-and-sweep, but with higher overhead.
It would be interesting to see if this affects aerys performance.
Indeed. I've tried running https://github.com/dbalabka/aerys-benchmark, and I've seen no differences before and after this PR. |
* PHP-8.0: [ci skip] NEWS Fix generator memory leaks when interrupted during argument evaluation (#9756)
* PHP-8.1: [ci skip] NEWS [ci skip] NEWS Fix generator memory leaks when interrupted during argument evaluation (#9756)
* PHP-8.2: [ci skip] NEWS [ci skip] NEWS [ci skip] NEWS Fix generator memory leaks when interrupted during argument evaluation (#9756)
Fixes #9750