Bug #76326 [Opn->Nab]: Exception lost with nested finally block

From: Date: Fri, 11 May 2018 11:10:21 +0000
Subject: Bug #76326 [Opn->Nab]: Exception lost with nested finally block
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215198@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76326&edit=1 ID: 76326 Updated by: nikic@php.net Reported by: nickpeirson at gmail dot com Summary: Exception lost with nested finally block -Status: Open +Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Linux (Ubuntu 14.04) PHP Version: 7.2.5 Block user comment: N Private report: N New Comment: This is an expected, if unfortunate, change in PHP 7: http://php.net/manual/en/migration70.incompatible.php#migration70.incompatible.other.func-parameter-modified Previous Comments: ------------------------------------------------------------------------ [2018-05-11 11:08:10] nickpeirson at gmail dot com Description: ------------ We were debugging an infinite loop caused by a developer calling a function with a value that they were post-decrementing instead of pre-decrementing, e.g. foo($a--) instead of foo(--$a). We had logs including stacktraces that showed that the function was being called as if it was pre-decremented, which completely threw us. Investigating further showed that the value that the function was being called with was different to the value that the stacktrace showed. Testing this on 3v4l.org (https://3v4l.org/KQaoc) showed that this used to work correctly up until PHP 5.6.30, however releases since 7.0.0 have this issue. For completeness, debug_print_backtrace() exhibits the same behaviour (https://3v4l.org/br8Co). Test script: --------------- function foo($a) { bar($a++); } function bar($a) { echo '$a = '.$a."\n"; echo (new Exception)->getTraceAsString(); } foo(1); Expected result: ---------------- $a = 1 #0 php shell code(1): bar(1) #1 php shell code(1): foo(1) #2 {main} Actual result: -------------- $a = 1 #0 php shell code(1): bar(1) #1 php shell code(1): foo(2) #2 {main} ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76326&edit=1

« previous php.bugs (#215198) next »