Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89851 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52951 invoked from network); 20 Dec 2015 20:53:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Dec 2015 20:53:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.172 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.160.172 mail-yk0-f172.google.com Received: from [209.85.160.172] ([209.85.160.172:35765] helo=mail-yk0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 20/1E-51216-33517765 for ; Sun, 20 Dec 2015 15:53:07 -0500 Received: by mail-yk0-f172.google.com with SMTP id v6so113002740ykc.2 for ; Sun, 20 Dec 2015 12:53:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=z+eMMb2FsOBEcdL7YtOGG6mSW9cWwdpv15fT5mefRio=; b=r87iDEjqkrbRmymiuIRO3ZI5ye7ohPFiGTk5QlsXAkP+4dxEm3TNmva43QssK5qJTz 93P2e9NnUd6/UG5WJ8lQCt02yvTZtWGXP5PTW7Ckoek9hoP6edS0TzdJENrxQBBVqJoZ 2fwSfDgObRVMGXNOVivnfsYeacpYF3lBsnhU784S17sHqylB5pcVZOsnyI860VK7v5bu lcpp5/XL/9iLdRPGvqldz7keuf054osJyEnu6K44iapMMEqmRtfEP0eOprVR+pdoCCrI R9U0voboy0dXXGuJ0AsDW7VqGehLL3DSnojesjGTVE7Hgz+jYFRcNM7zcMWhycWQNeGi plsw== MIME-Version: 1.0 X-Received: by 10.129.33.65 with SMTP id h62mr11729324ywh.139.1450644784164; Sun, 20 Dec 2015 12:53:04 -0800 (PST) Received: by 10.129.128.68 with HTTP; Sun, 20 Dec 2015 12:53:04 -0800 (PST) In-Reply-To: References: Date: Sun, 20 Dec 2015 21:53:04 +0100 Message-ID: To: Derick Rethans Cc: Dmitry Stogov , PHP Developers Mailing List Content-Type: multipart/alternative; boundary=001a114264340e394805275a8f40 Subject: Re: CATCH in master (vs 7.0) From: nikita.ppv@gmail.com (Nikita Popov) --001a114264340e394805275a8f40 Content-Type: text/plain; charset=UTF-8 On Sun, Dec 20, 2015 at 9:06 PM, Derick Rethans wrote: > Hi! > > I've been making sure Xdebug (and vld) compile with master as well - and > while doing so I was retrofitting CATCH to use the extended value as a > relative jump point (instead of absolute). Like: > > PHP 7.0: > vld_printf (stderr, ", ->%d", op.extended_value); > > PHP 7.1: > vld_printf (stderr, ", ->%d", nr + ((int) op.extended_value / > sizeof(zend_op))); > > This works fine, and CATCH now shows: > 18 46 E > > CATCH > 'ExceptionFoo', !2, ->50 > again, instead of ->128 > > However, the last CATCH, has a negative jump back to position 0 in PHP > 7.1: > > 22 54 E > > CATCH > 'ExceptionBaz', !2, ->0 > > Instead of what it does for PHP 7.0, jump to after the CATCH state: > > 22 54 E > > CATCH > 'ExceptionBaz', !2, ->57 > > > The whole section from VLD is: > > 17 43 > EXT_STMT > 44 ECHO > 'Not+thrown%0A' > 45 > JMP > ->57 > 18 46 E > > CATCH > 'ExceptionFoo', !2, ->50 > 19 47 > EXT_STMT > 48 ECHO > 'caught%0A' > 49 > JMP > ->57 > 20 50 E > > CATCH > 'ExceptionBar', !2, ->54 > 21 51 > EXT_STMT > 52 ECHO > 'caught%0A' > 53 > JMP > ->57 > 22 54 E > > CATCH > 'ExceptionBaz', !2, ->0 *** > 23 55 > EXT_STMT > 56 ECHO > 'caught%0A' > 26 57 > EXT_STMT > 58 ECHO > 'And+do+some+more%0A' > 27 59 EXT_STMT > 60 > RETURN > null > > > *** is where the change happens from 57 to 0. However, I can't find *why* > this > happens, and whether it is actually correct? In the executor I can't see > a separate check for "0" either - even if that is correct. What's the deal > here? > > Then again, the logic sees the ->0 or ->57 both as an exit, as > opcode.result.num == 1 for the 3rd catch. In zend_vm_execute, they do this, > instead of the jump: > > if (opline->result.num) { > zend_throw_exception_internal(NULL); > HANDLE_EXCEPTION(); > } > > The file for which this happens is > http://derickrethans.nl/files/dump/bug01034-003.txt > > cheers, > Derick > The extended_value JMP_ADDR is only used if opline->result.num is 0. opline->result.num here serves as a flag whether it is the last catch in the sequence. If so, there is no further catch to jump to and instead the exception is rethrown. extended_value will be some meaningless dummy value in that case. For VLD you should hide the value if opline->result.num is set, similar to what zend_dump does: http://lxr.php.net/xref/PHP_TRUNK/ext/opcache/Optimizer/zend_dump.c#644 Nikita --001a114264340e394805275a8f40--