#45895 [Opn->Fbk]: Exception in set_error_handler() messes up backtrace args

From: Date: Tue, 26 Aug 2008 22:36:19 +0000
Subject: #45895 [Opn->Fbk]: Exception in set_error_handler() messes up backtrace args
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-128442@lists.php.net to get a copy of this message
ID: 45895 Updated by: jani@php.net Reported By: jmcgraw1 at gmail dot com -Status: Open +Status: Feedback Bug Type: Scripting Engine problem Operating System: CentOS PHP Version: 5.2.6 New Comment: Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows (zip): http://snaps.php.net/win32/php5.2-win32-latest.zip For Windows (installer): http://snaps.php.net/win32/php5.2-win32-installer-latest.msi Previous Comments: ------------------------------------------------------------------------ [2008-08-22 21:52:57] jmcgraw1 at gmail dot com 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 this bug report at http://bugs.php.net/?id=45895&edit=1

« previous php.bugs (#128442) next »