Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88903 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40183 invoked from network); 21 Oct 2015 14:38:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Oct 2015 14:38:19 -0000 Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:59538] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 21/30-36764-853A7265 for ; Wed, 21 Oct 2015 10:38:17 -0400 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 6E5AE10C01F; Wed, 21 Oct 2015 15:38:12 +0100 (BST) Date: Wed, 21 Oct 2015 15:38:12 +0100 (BST) X-X-Sender: derick@whisky.home.derickrethans.nl To: Bob Weinand cc: Xinchen Hui , Dmitry Stogov , PHP Developers Mailing List In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-736442942-1445438259=:10651" Subject: Re: [PHP-DEV] Issues with exceptions and overloading opcodes From: derick@php.net (Derick Rethans) --8323329-736442942-1445438259=:10651 Content-Type: text/plain; CHARSET=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Tue, 20 Oct 2015, Bob Weinand wrote: > > Am 20.10.2015 um 18:08 schrieb Derick Rethans : > >=20 > > On Tue, 20 Oct 2015, Bob Weinand wrote: > >=20 > >>> Am 20.10.2015 um 17:11 schrieb Xinchen Hui : > >>>=20 > >>> On Tue, Oct 20, 2015 at 10:45 PM, Derick Rethans > wrote: > >>>=20 > >>>> When hacking on Xdebug for PHP 7, I ran into some issues where=20 > >>>> PHP would just spin around. This happens when there is an=20 > >>>> exception, and I use overloaded opcodes. I wrote a small example=20 > >>>> extension at=20 > >>>> https://github.com/derickr/php-minimal-opcode-overloading-example=20 > >>>> with a test case (=20 > >>>> https://github.com/derickr/php-minimal-opcode-overloading-example/bl= ob/master/tests/test.php=20 > >>>> ) that shows that something is looping in executing opcodes, as=20 > >>>> the HANDLE_EXCEPTION iirc doesn't advance to the next opline. I=20 > >>>> believe this is a recent enough change, as it only started=20 > >>>> happening after I upgraded from about RC1 to latest master. > >>>>=20 > >>>> Would you care to have a look? > >>>>=20 > >>> This is introduced by a fix made by Bob,=20 > >>> https://github.com/php/php-src/commit/808f62bb=20 > >>> > >>>=20 > >>> Bob, I am going to revert this for now, since you didn't include a=20 > >>> test script to show where the problem was, I am not sure why you=20 > >>> made this? > >>=20 > >> I didn't add any test case as we don't have any APIs in php-src=20 > >> using that user_opcode handler. I discussed the change back then=20 > >> with Dmitry and committed with his review. > >>=20 > >> It concretely broke uopz which might throw an exception itself. And=20 > >> in turn we realized that for integrity we need to ensure that=20 > >> opline =3D=3D EX(opline) else we'll end up with different behavior in= =20 > >> global register builds and normal builds. > >>=20 > >> In general, you should not overload ZEND_HANDLE_EXCEPTION (if you=20 > >> need to, have a special handling for it, but never directly=20 > >> dispatch to it). It is quite special being the only opcode actually=20 > >> allowing EG(exception) to be non-NULL at the start of it. > >>=20 > >> You are doing an #ifdef ZTS to exempt it=E2=80=A6 why don't you always= =20 > >> exempt it? > >=20 > > Even if I do (like I've just pushed into the extension), the test=20 > > still fails because the code loops. So you did break something. >=20 > Ah, ZEND_CATCH indeed also allows EG(exception) to be non-null=E2=80=A6 >=20 > =E2=80=A6 maybe I should write >=20 > if (EG(exception) > && opline->opcode !=3D ZEND_HANDLE_EXCEPTION && opline->opcode !=3D ZEND= _CATCH > && ret !=3D ZEND_USER_OPCODE_DISPATCH && ret !=3D ZEND_USER_OPCODE_RETUR= N && ret !=3D ZEND_USER_OPCODE_ENTER && ret !=3D ZEND_USER_OPCODE_LEAVE) { > HANDLE_EXCEPTION(); > } >=20 > to allow dispatching for these two opcodes too? I don't know. Dmitry, Xinchen? I'd like to get this resolved soon.. cheers, Derick --8323329-736442942-1445438259=:10651--