Bug #76326 [NEW]: Exception lost with nested finally block

From: Date: Fri, 11 May 2018 11:08:12 +0000
Subject: Bug #76326 [NEW]: Exception lost with nested finally block
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215197@lists.php.net to get a copy of this message
From: nickpeirson at gmail dot com Operating system: Linux (Ubuntu 14.04) PHP version: 7.2.5 Package: Scripting Engine problem Bug Type: Bug Bug description:Exception lost with nested finally block 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 bug report at https://bugs.php.net/bug.php?id=76326&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76326&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76326&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76326&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76326&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76326&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76326&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76326&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76326&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76326&r=support Expected behavior: https://bugs.php.net/fix.php?id=76326&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76326&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76326&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76326&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76326&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76326&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76326&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76326&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76326&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76326&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76326&r=mysqlcfg

« previous php.bugs (#215197) next »