Re: com php-src: Implement argument unpacking: Zend/tests/arg_unpack/basic.phpt Zend/tests/arg_unpack/by_ref.phpt Zend/tests/arg_unpack/dynamic.phpt
Zend/tests/arg_unpack/internal.phpt Zend/tests/arg_unpack/invalid_type.phpt Zend/tests/arg_unpack/method.phpt Zend/tests/arg_unpack/new.phpt
Zend/tests/arg_unpack/string_keys.phpt Zend/tests/arg_unpack/traversable_throwing_exception.phpt
Zend/tests/arg_unpack/traversable_with_by_ref_parameters.phpt Zend/
| From: | Nikita Popov | Date: | Mon, 13 Jan 2014 17:11:00 +0000 |
| Subject: | Re: com php-src: Implement argument unpacking: Zend/tests/arg_unpack/basic.phpt Zend/tests/arg_unpack/by_ref.phpt Zend/tests/arg_unpack/dynamic.phpt Zend/tests/arg_unpack/internal.phpt Zend/tests/arg_unpack/invalid_type.phpt Zend/tests/arg_unpack/method.phpt Zend/tests/arg_unpack/new.phpt Zend/tests/arg_unpack/string_keys.phpt Zend/tests/arg_unpack/traversable_throwing_exception.phpt Zend/tests/arg_unpack/traversable_with_by_ref_parameters.phpt Zend/ |
||
| References: | 1 2 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-75597@lists.php.net to get a copy of this message | ||
On Mon, Jan 13, 2014 at 9:56 AM, Dmitry Stogov <dmitry@zend.com> wrote:
> Hi Nikita,
>
> It seems like your patch is not compatible with opcache.
> At least the following new tests crash with opcache enabled (-d
> opcache.enable=1 -d opcache.enable_cli=1 -d opcache.optimization_level=-1).
> It must be something related to optimization pass 4 -
> ext/opcache/Optimizer/optimize_func_calls.c
>
> Basic argument unpacking [Zend/tests/arg_unpack/basic.phpt]
> Argument unpacking with by-ref arguments
> [Zend/tests/arg_unpack/by_ref.phpt]
> Only arrays and Traversables can be unpacked
> [Zend/tests/arg_unpack/invalid_type.phpt]
> Argument unpacking does not work with string keys (forward compatibility
> for named args) [Zend/tests/arg_unpack/string_keys.phpt]
> Traversables that throw exceptions are properly handled during argument
> unpack [Zend/tests/arg_unpack/traversable_throwing_exception.phpt]
> Traversables cannot be unpacked into by-reference parameters
> [Zend/tests/arg_unpack/traversable_with_by_ref_parameters.phpt]
>
Thanks for the notice, I probably used wrong ini options when trying
opcache. I think the fix is to add the following lines into the
optimize_func_calls switch:
#if ZEND_EXTENSION_API_NO >= PHP_5_6_X_API_NO
case ZEND_SEND_UNPACK:
call_stack[call - 1].func = NULL;
call_stack[call - 1].opline = NULL;
break;
#endif
But I can't test this right now as opcache always segfaults during
accel_shutdown (something with interned strings). I'll have to figure that
out first.
> I took just a quick look over the patch and think that it may has another
> problem.
> PHP compiler calculates the necessary argument stack and then VM allocates
> it at once together with execeute_data.
> The "argument unpacking" doesn't allow this. The patch tries to extend
> stack at run-time, but it may work improperly.
> For example when we are at stack boundary and execute something like
> test(...array(1,2), 3, 4);
> ZEND_VM_STACK_GROW_IF_NEEDED() won't extend stack because compiler
> preallocated space for "3" and "4", and it'll lead to pushing above
> stack
> boundary.
>
Hmm, that's a very good point. This looks not so easy to fix. I'll try to
find some solution and alternatively forbid trailing fixed arguments.
> Nikita, I very appreciate your work and mostly very glad with its quality.
> But as you often work on the very core parts, could you, please, ping me
> before committing such serious changes.
>
Yes, sure! Sorry for not pinging you this time.
Nikita