-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Improve memory allocation related code in zend_fibers #7058
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
twose
commented
May 27, 2021
- make_fcontext() never returns NULL.
- Show syscall error info in exception just like zend_alloc does (it also use php_win32_error_msg_free() in Zend).
- MAP_ANON was marked as deprecated or compatibility macro on Linux, It would be better to use MAP_ANONYMOUS first.
- Makes the code consistent with the code of other modules in the kernel.
- adds some comments.
I am trying to work on some simple parts first :) |
bump resolve conflicts for easy testing ... PS, this looks testable with an --INI-- section ? |
@@ -481,7 +494,6 @@ ZEND_API void zend_fiber_start(zend_fiber *fiber, zval *params, uint32_t param_c | |||
fiber->fci.named_params = named_params; | |||
|
|||
if (!zend_fiber_init_context(&fiber->context, zend_fiber_execute, EG(fiber_stack_size))) { | |||
zend_throw_exception(NULL, "Could not create fiber context", 0); |
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 was intentionally throwing an Exception
, not Error
, because it does not indicate a programming error but an environment error that is can happen during normal operation (normally, if more than 65k fibers are created).
Though maybe it should use something more specific than just Exception
.
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 was intentionally throwing an
Exception
, notError
Sorry... I know that. It's a typo error... I just copy the code from my implementation version and remove the zend_ce_fiber_exception
because we have not declared it, I never noticed that I misuse zend_throw_error
instead of using zend_throw_exception_ex
to throw an exception so it becomes Error
here...
Though maybe it should use something more specific than just Exception.
So should we declare FiberException
here?
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.
Other than switching the memory alloc/protect errors back to Exception
or a sub-class thereof, LGTM.
- make_fcontext() never returns NULL. - Show syscall error info in exception just like zend_alloc does (it also use php_win32_error_msg_free() in Zend). - MAP_ANON was marked as deprecated or compatibility macro on Linux, It would be better to use MAP_ANONYMOUS first. - Makes the code consistent with the code of other modules in the kernel. - adds some comments.