From: jmcgraw1 at gmail dot com Operating system: CentOS PHP version: 5.2.6 PHP Bug Type: Scripting Engine problem Bug description: Exception in set_error_handler() messes up backtrace args
Description: ------------ Throwing an exception within set_error_handler() produces an exception which produces a messed up backtrace. Each entry within the backtrace contains the 'args' for the previous call, with the most immediate entry missing its 'args'. In the case of my example below the string 'foobar' should be in the array 'args' for the call to B(), not A(). Reproduce code: --------------- function handle_errors() { throw new ErrorException(); } set_error_handler('handle_errors', E_ALL); function A() { $foo->bar; // Purposely cause error } function B($c) { A(); } try { B('foobar'); } catch (Exception $e) { var_dump($e->getTrace()); } Expected result: ---------------- array(3) { [0]=> array(4) { ["file"]=> string(42) "/home/public/pdt/framework/html/error.php" ["line"]=> int(10) ["function"]=> string(13) "handle_errors" ["args"]=> array(0) { } } [1]=> array(4) { ["file"]=> string(42) "/home/public/pdt/framework/html/error.php" ["line"]=> int(14) ["function"]=> string(1) "A" } [2]=> array(3) { ["file"]=> string(42) "/home/public/pdt/framework/html/error.php" ["line"]=> int(18) ["function"]=> string(1) "B" ["args"]=> array(1) { [0]=> string(6) "foobar" } } } Actual result: -------------- array(3) { [0]=> array(4) { ["file"]=> string(42) "/home/public/pdt/framework/html/error.php" ["line"]=> int(10) ["function"]=> string(13) "handle_errors" ["args"]=> array(0) { } } [1]=> array(4) { ["file"]=> string(42) "/home/public/pdt/framework/html/error.php" ["line"]=> int(14) ["function"]=> string(1) "A" ["args"]=> array(1) { [0]=> string(6) "foobar" } } [2]=> array(3) { ["file"]=> string(42) "/home/public/pdt/framework/html/error.php" ["line"]=> int(18) ["function"]=> string(1) "B" } } -- Edit bug report at http://bugs.php.net/?id=45895&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45895&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45895&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45895&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45895&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45895&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45895&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45895&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45895&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45895&r=support Expected behavior: http://bugs.php.net/fix.php?id=45895&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45895&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45895&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45895&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45895&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45895&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45895&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45895&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45895&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45895&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45895&r=mysqlcfg