-
Notifications
You must be signed in to change notification settings - Fork 5
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
Test failure with 8.3.0RC1 #19
Comments
@remicollet, I noticed the following note in the UPGRADING.INTERNALS file:
Since libeio uses a custom thread to execute the user callback passed to I've successfully resolved the issue with the following patch: diff --git a/php8/php_eio.c b/php8/php_eio.c
index e79d10f..c87ca82 100644
--- a/php8/php_eio.c
+++ b/php8/php_eio.c
@@ -479,6 +479,10 @@ static void php_eio_custom_execute(eio_req *req)
ZVAL_NULL(&zarg);
}
+#ifdef ZEND_CHECK_STACK_LIMIT
+ zend_call_stack_init();
+#endif
+
zend_call_method(Z_ISUNDEF(pf->obj) ? NULL : Z_OBJ_P(&pf->obj), pf->ce, &pf->func_ptr,
ZSTR_VAL(pf->func_ptr->common.function_name),
ZSTR_LEN(pf->func_ptr->common.function_name),
@@ -863,8 +867,11 @@ static inline void php_eio_init()
pid_t cur_pid = getpid();
if (php_eio_pid <= 0 || (php_eio_pid > 0 && cur_pid != php_eio_pid)) {
- /* Uninitialized or forked a process(which needs it's own eio pipe) */
+#ifdef ZEND_CHECK_STACK_LIMIT
+ zend_call_stack_init();
+#endif
+ /* Uninitialized or forked a process(which needs it's own eio pipe) */
if (php_eio_pipe_new()) {
php_error_docref(NULL, E_ERROR,
"Failed creating internal pipe: %s", strerror(errno)); The patch invokes
I'm particularly uncertain about the first instance. You thoughts on this? |
There is also EIO_STACKSIZE compile-time option in the config.m4. Do you think I should tweak it as well? |
Perhaps @arnaud-lb may help on this ? (as the author of the PHP change) |
This is the right approach 👍 Threads have their own stack, so You also need to restore the previous value of It's probably worth it to cache the value of |
@rosmanov testing 3.1.0RC1 with your patch, build OK and test suite passes |
@arnaud-lb, thank you for your answer! It's nice to hear that I'm on the right track. However, I'm still unsure about a couple of points:
|
It's the right way then. You just need to restore the original stack addresses after executing the callback: diff --git a/php8/php_eio.c b/php8/php_eio.c
index e79d10f..2d5bed5 100644
--- a/php8/php_eio.c
+++ b/php8/php_eio.c
@@ -473,6 +473,10 @@ static void php_eio_custom_execute(eio_req *req)
pf = &eio_cb->func_exec;
if (EXPECTED(pf->func_ptr)) {
+ void *stack_limit = EG(stack_limit);
+ void *stack_base = EG(stack_base);
+ zend_call_stack_init();
+
if (! Z_ISUNDEF(eio_cb->arg)) {
ZVAL_COPY(&zarg, &eio_cb->arg);
} else {
@@ -494,6 +498,9 @@ static void php_eio_custom_execute(eio_req *req)
zend_exception_restore();
zval_ptr_dtor(&zarg);
+
+ EG(stack_limit) = stack_limit;
+ EG(stack_base) = stack_base;
}
#endif /* ZTS */
} If I understand correctly, the main thread never executes PHP code during
I'm not sure. If PHP code can be executed in the main thread after that, you need to restore the stack addresses.
If that's an issue, maybe you can cache the stack addresses in thread-specific data. I wouldn't attempt that before benchmarking though. |
NB: Beware of zval_ptr_dtor(), since it can execute destructors. You need to move the |
@remicollet, I hope that fixes the issue. I've uploaded a new PECL release version 3.0.1. Thank you guys. |
Thanks for 3.0.1 Do you have any plans to release 3.1.0 soon? RC1 is 3 months old, and as there is no previous stable version of 3.x, 3.1.0RC1 was the version available to RPM users |
Additional notice: In source code, version was 3.0.0RC5, but it was released on pecl as 3.1.0RC1 (no tag here) |
Do you think I could just bump version to 3.1.0 (stable)? |
Uploaded eio-3.1.0. Thanks |
The text was updated successfully, but these errors were encountered: