Re: Issues with exceptions and overloading opcodes
| From: | Derick Rethans | Date: | Tue, 20 Oct 2015 16:08:26 +0000 |
| Subject: | Re: Issues with exceptions and overloading opcodes | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-88892@lists.php.net to get a copy of this message | ||
On Tue, 20 Oct 2015, Bob Weinand wrote:
> > Am 20.10.2015 um 17:11 schrieb Xinchen Hui <laruence@php.net>:
> >
> > On Tue, Oct 20, 2015 at 10:45 PM, Derick Rethans <derick@php.net
> > <mailto:derick@php.net>> wrote:
> >
> >> When hacking on Xdebug for PHP 7, I ran into some issues where PHP
> >> would just spin around. This happens when there is an exception,
> >> and I use overloaded opcodes. I wrote a small example extension at
> >>
> >> https://github.com/derickr/php-minimal-opcode-overloading-example
> >> with a test case (
> >>
> >> https://github.com/derickr/php-minimal-opcode-overloading-example/blob/master/tests/test.phpÛ�|äs;
> >> gz•Ö‰0Ì
> >> ) that shows that something is looping in executing opcodes, as the
> >> HANDLE_EXCEPTION iirc doesn't advance to the next opline. I believe
> >> this is a recent enough change, as it only started happening after
> >> I upgraded from about RC1 to latest master.
> >>
> >> Would you care to have a look?
> >>
> > This is introduced by a fix made by Bob,
> > https://github.com/php/php-src/commit/808f62bb
> > <https://github.com/php/php-src/commit/808f62bb>
> >
> > Bob, I am going to revert this for now, since you didn't include a
> > test script to show where the problem was, I am not sure why you
> > made this?
>
> I didn't add any test case as we don't have any APIs in php-src using
> that user_opcode handler. I discussed the change back then with Dmitry
> and committed with his review.
>
> It concretely broke uopz which might throw an exception itself. And in
> turn we realized that for integrity we need to ensure that opline ==
> EX(opline) else we'll end up with different behavior in global
> register builds and normal builds.
>
> In general, you should not overload ZEND_HANDLE_EXCEPTION (if you need
> to, have a special handling for it, but never directly dispatch to
> it). It is quite special being the only opcode actually allowing
> EG(exception) to be non-NULL at the start of it.
>
> You are doing an #ifdef ZTS to exempt it… why don't you always exempt
> it?
Even if I do (like I've just pushed into the extension), the test still
fails because the code loops. So you did break something.
cheers,
Derick