From: flummi at everymail dot net
Operating system: Redhat Linux
PHP version: 5.0.4
PHP Bug Type: Unknown/Other Function
Bug description: debug_backtrace shows wrong arguments when called from an own
error handler
Description:
------------
When calling debug_backtrace from an own error handler, it provides a
different output than when calling it directly. As you can see in the
code, I have two calls to debug_backtrace, one from my error handler, the
other from a function. As I raise an error shortly after calling
debug_backtrace the first time, I would expect to have the same first few
entries in the debug_backtrace array. I.e. the last entry shows an error
on line 18, where the function 'a_test' is called with arg 'another
friend'. In real this function is called with the arg 'friend' (arg
'another friend' is used in the next function call.
I hope I could explain the bug good enough as my natural language is
german. :-)
Reproduce code:
---------------
<pre>
<?php
function HandleError($n, $m, $f, $l){
print_r(debug_backtrace());
}
set_error_handler('HandleError');
function a_test($str)
{
echo "\nHi: $str";
b_test("another friend");
}
function b_test($str2)
{
echo "\nHi $str2";
print_r(debug_backtrace());
echo "now raise an error..".(2/0);
}
a_test('friend');
?>
</pre>
Expected result:
----------------
Hi: friend
Hi another friendArray
(
[0] => Array
(
[file] => /var/www/html/xiview/test/testerror2.php
[line] => 10
[function] => b_test
[args] => Array
(
[0] => another friend
)
)
[1] => Array
(
[file] => /var/www/html/xiview/test/testerror2.php
[line] => 18
[function] => a_test
[args] => Array
(
[0] => friend
)
)
)
Array
(
[0] => Array
(
[file] => /var/www/html/xiview/test/testerror2.php
[line] => 16
[function] => HandleError
)
[1] => Array
(
[file] => /var/www/html/xiview/test/testerror2.php
[line] => 16
[function] => b_test
)
[2] => Array
(
[file] => /var/www/html/xiview/test/testerror2.php
[line] => 10
[function] => b_test
[args] => Array
(
[str2] => another friend
)
)
[3] => Array
(
[file] => /var/www/html/xiview/test/testerror2.php
[line] => 18
[function] => a_test
[args] => Array
(
[0] => friend
)
)
)
Actual result:
--------------
Hi: friend
Hi another friendArray
(
[0] => Array
(
[file] => /var/www/html/xiview/test/testerror2.php
[line] => 10
[function] => b_test
[args] => Array
(
[0] => another friend
)
)
[1] => Array
(
[file] => /var/www/html/xiview/test/testerror2.php
[line] => 18
[function] => a_test
[args] => Array
(
[0] => friend
)
)
)
Array
(
[0] => Array
(
[file] => /var/www/html/xiview/test/testerror2.php
[line] => 16
[function] => HandleError
)
[1] => Array
(
[file] => /var/www/html/xiview/test/testerror2.php
[line] => 16
[function] => b_test
)
[2] => Array
(
[file] => /var/www/html/xiview/test/testerror2.php
[line] => 10
[function] => b_test
[args] => Array
(
[0] => 2
[1] => Division by zero
[2] => /var/www/html/xiview/test/testerror2.php
[3] => 16
[4] => Array
(
[str2] => another friend
)
)
)
[3] => Array
(
[file] => /var/www/html/xiview/test/testerror2.php
[line] => 18
[function] => a_test
[args] => Array
(
[0] => another friend
)
)
)
--
Edit bug report at http://bugs.php.net/?id=34175&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34175&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=34175&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=34175&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34175&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34175&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34175&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34175&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34175&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34175&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34175&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=34175&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=34175&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34175&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34175&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34175&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34175&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34175&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34175&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34175&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34175&r=mysqlcfg