Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88895 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54145 invoked from network); 20 Oct 2015 19:05:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Oct 2015 19:05:42 -0000 Authentication-Results: pb1.pair.com header.from=bobwei9@hotmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=bobwei9@hotmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hotmail.com designates 65.55.111.110 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.110 blu004-omc2s35.hotmail.com Received: from [65.55.111.110] ([65.55.111.110:65202] helo=BLU004-OMC2S35.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 54/31-45576-28096265 for ; Tue, 20 Oct 2015 15:05:40 -0400 Received: from BLU436-SMTP145 ([65.55.111.71]) by BLU004-OMC2S35.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Tue, 20 Oct 2015 12:05:35 -0700 X-TMN: [FZSnCLIRRG/7/4Z/zj2lLODA0U3/l74N] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 (Mac OS X Mail 9.0 \(3094\)) In-Reply-To: Date: Tue, 20 Oct 2015 21:05:30 +0200 CC: Derick Rethans , PHP Developers Mailing List Content-Transfer-Encoding: quoted-printable References: To: Xinchen Hui , Dmitry Stogov X-Mailer: Apple Mail (2.3094) X-OriginalArrivalTime: 20 Oct 2015 19:05:32.0707 (UTC) FILETIME=[4B3B4730:01D10B6A] Subject: Re: [PHP-DEV] Issues with exceptions and overloading opcodes From: bobwei9@hotmail.com (Bob Weinand) > 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 PHP=20= >>>> would just spin around. This happens when there is an exception,=20 >>>> and I use overloaded opcodes. I wrote a small example 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/blob/mas= ter/tests/test.php=20 >>>> ) that shows that something is looping in executing opcodes, as the=20= >>>> HANDLE_EXCEPTION iirc doesn't advance to the next opline. I believe=20= >>>> this is a recent enough change, as it only started happening after=20= >>>> 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 using=20= >> that user_opcode handler. I discussed the change back then with = Dmitry=20 >> and committed with his review. >>=20 >> It concretely broke uopz which might throw an exception itself. And = in=20 >> turn we realized that for integrity we need to ensure that opline =3D=3D= =20 >> EX(opline) else we'll end up with different behavior in global=20 >> register builds and normal builds. >>=20 >> In general, you should not overload ZEND_HANDLE_EXCEPTION (if you = need=20 >> to, have a special handling for it, but never directly dispatch to=20 >> it). It is quite special being the only opcode actually allowing=20 >> 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 exempt=20 >> it? >=20 > Even if I do (like I've just pushed into the extension), the test = still=20 > fails because the code loops. So you did break something. >=20 > cheers, > Derick > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php Ah, ZEND_CATCH indeed also allows EG(exception) to be non-null=E2=80=A6 =E2=80=A6 maybe I should write 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_RETURN && ret !=3D ZEND_USER_OPCODE_ENTER && ret !=3D = ZEND_USER_OPCODE_LEAVE) { HANDLE_EXCEPTION(); } to allow dispatching for these two opcodes too? Bob=