Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93474 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57300 invoked from network); 24 May 2016 07:46:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 May 2016 07:46:02 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 65.55.169.102 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 65.55.169.102 mail-bl2on0102.outbound.protection.outlook.com Received: from [65.55.169.102] ([65.55.169.102:17483] helo=na01-bl2-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CE/83-37212-7B604475 for ; Tue, 24 May 2016 03:46:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=RWSoftware.onmicrosoft.com; s=selector1-zend-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=W4ZF0KFQXmqoUrP64qEGkX13vPPFjgpDyZACeWCLGYs=; b=X7C4dAhh7PnUPj3ZtveQDqxzJxNQ8B06SfpaJlFaxtPFxGw27Dy23wowR7Btv29aQGgUmr4xOW2vot+h7Q3DFpixwL849Tgecf0RxSO6IY8gePpHdF4yJq54JKDMwdc0RDXKtmVDfOIJ2zhZ7pjrJ7lhuNni7F0d0uLzVQy4Efo= Received: from BY2PR0201MB1784.namprd02.prod.outlook.com (10.163.72.26) by SN1PR02MB1710.namprd02.prod.outlook.com (10.162.129.28) with Microsoft SMTP Server (TLS) id 15.1.497.12; Tue, 24 May 2016 07:45:56 +0000 Received: from BY2PR0201MB1784.namprd02.prod.outlook.com ([10.163.72.26]) by BY2PR0201MB1784.namprd02.prod.outlook.com ([10.163.72.26]) with mapi id 15.01.0501.013; Tue, 24 May 2016 07:45:55 +0000 To: Nikita Popov CC: Xinchen Hui , internals Thread-Topic: "finally" handling refactoring (Bug #72213) Thread-Index: AQHRsooB/asZC+6F5UyFZdE4B+ax2p/B2ROAgASM9cCAAFQwgIAAiVqA///XwICAAJ7QCg== Date: Tue, 24 May 2016 07:45:55 +0000 Message-ID: References: , In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=none action=none header.from=zend.com; x-originating-ip: [132.245.81.165] x-ms-office365-filtering-correlation-id: 1707ccd8-6127-458c-90c0-08d383a7705c x-microsoft-exchange-diagnostics: 1;SN1PR02MB1710;5:fK6SkkHLin/Mf3Y+uBoX1dUQC8c0YEh+nYqjT2JJQ84pqIk+Jg/f5Pf+SJ6U/k0MQFncL1pNkyWJfqF3E/yuL+4rQOp8d/7UEOXzfyaS96vfmhtuQvqum2lq+RpJw5M8+VHxoSnN2qynNxhV9Cc1pw==;24:w79Pd6IoLooIclIVEk66lVi9iMQj+6SqZP0YMB7oc0E3MfkugXASxNDouEHq2w4ZqzyXs5FBnou7/mFATiUQ7jA8vQsO97J71jNEtYdJGL0=;7:H8KX6Gkp7Jx8R1BQU2JevyzHQZtLpSXrzm/92lkH/bFmnBOcZ7GvLbQ6wbxZXRrvU6v3sxBP5ngNVnQ6/jFtP9eaArPJjh7BCBZJeXxe5QSx132llrF/ZXw59W1+RvhOxjCQBnEkgZ9qWXMI2pKA/q3ZDICBxiDpXzRIUOrYLbdQpar0xcIjlcA5iJKsJmnl x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR02MB1710; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046);SRVR:SN1PR02MB1710;BCL:0;PCL:0;RULEID:;SRVR:SN1PR02MB1710; x-forefront-prvs: 09525C61DB x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(51444003)(377454003)(24454002)(99286002)(110136002)(575784001)(4326007)(81166006)(106116001)(5002640100001)(122556002)(76576001)(8936002)(50986999)(76176999)(54356999)(66066001)(5003600100002)(5008740100001)(19617315012)(6116002)(2906002)(33656002)(9686002)(586003)(19627405001)(19625215002)(74316001)(16236675004)(1220700001)(93886004)(189998001)(3846002)(102836003)(77096005)(15975445007)(5004730100002)(86362001)(19580395003)(19580405001)(8676002)(3660700001)(10400500002)(2950100001)(3280700002)(2900100001)(87936001)(92566002);DIR:OUT;SFP:1102;SCL:1;SRVR:SN1PR02MB1710;H:BY2PR0201MB1784.namprd02.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: multipart/alternative; boundary="_000_BY2PR0201MB178400103CA4255121229471BF4F0BY2PR0201MB1784_" MIME-Version: 1.0 X-OriginatorOrg: zend.com X-MS-Exchange-CrossTenant-originalarrivaltime: 24 May 2016 07:45:55.1958 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 32210298-c08b-4829-8097-6b12c025a892 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR02MB1710 Subject: Re: "finally" handling refactoring (Bug #72213) From: dmitry@zend.com (Dmitry Stogov) --_000_BY2PR0201MB178400103CA4255121229471BF4F0BY2PR0201MB1784_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Ok. One more attempt with both tests fixed. https://github.com/php/php-src/pull/1919 Nikita, you may take a look only into the last commit. Do you see any other problems? Sorry for abusing your time, but your feedback is extremely useful. Thanks. Dmitry. Thanks. Dmitry. ________________________________ From: Nikita Popov Sent: Tuesday, May 24, 2016 1:12:31 AM To: Dmitry Stogov Cc: Xinchen Hui; internals Subject: Re: "finally" handling refactoring (Bug #72213) On Mon, May 23, 2016 at 11:36 PM, Dmitry Stogov > wrote: Hi, On 05/23/2016 07:24 PM, Nikita Popov wrote: On Mon, May 23, 2016 at 1:25 PM, Dmitry Stogov > wrote: Thanks for review. Both problems should be fixed now https://gist.github.com/dstogov/0a809891c6a3ac3fa= c4bd0d9711dd330 Do you see any other problems or a better way to fix this? Your fix for DISCARD_EXCEPTION does not look right to me. It will discard a= ll exceptions too early. For example: function test() { try { throw new Exception(1); } finally { try { try { } finally { return 42; } } finally { throw new Exception(2); } } } test(); This will now not chain exception 1 and 2, because exception 1 is discarded= at the return statement. I thought about this, and I think that the current behavior is right. If we remove "throw new Exception(2);" the first exception is going to be d= iscarded at "return 42;". I think we should do the same independently from the context. Why do you think Exception(1) should be kept? Because Exception(3) may be discarded by another catch in the finally, in w= hich case we should throw Exception(1). Consider this case: function test() { try { throw new Exception(1); } finally { try { try { try { } finally { return 42; } } finally { throw new Exception(3); } } catch (Exception $e) {} } } test(); This should throw Exception(1), as Exception(3) is thrown and caught inside= the finally block. I thought your current patch would not throw anything i= n this case, but I'm actually getting an assertion failure (and a condition= al jump on uninit value in valgrind): php: /home/nikic/php-src/Zend/zend_gc.c:226: gc_possible_root: Assertion `(= ref)->gc.u.v.type =3D=3D 7 || (ref)->gc.u.v.type =3D=3D 8' failed. I think this should be handled the same way we do the fast_call dispatch on= return, i.e. when we pop the FAST_CALL from the loop var stack we should r= eplace it with a DISCARD_EXCEPTION and then pop it after the finally. This = should generate all the necessary DISCARD_EXCEPTION opcodes, and in the rig= ht order. May be I'll commit the existing fix, and you'll try to implement this idea = on top? Thanks. Dmitry. Nikita --_000_BY2PR0201MB178400103CA4255121229471BF4F0BY2PR0201MB1784_--