php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34110 debug_print_backtrace prints wrong arguments
Submitted: 2005-08-12 23:04 UTC Modified: 2005-08-13 00:31 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: iblue at gmx dot net Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.0.4 OS: Linux
Private report: No CVE-ID: None
 [2005-08-12 23:04 UTC] iblue at gmx dot net
Description:
------------
debug_print_backtrace() and debug_backtrace() give both the same wrong results in combination with set_error_handler().
-----------------
php5 -v
PHP 5.0.4-1.dotdeb.2 (cli) (built: Jun 28 2005 12:17:46)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies
----------------- 

Reproduce code:
---------------
<?php
  set_error_handler("errorhandler");
  function errorhandler($errno, $errstr, $errfile, $errline
  {
    debug_print_backtrace();
  }
  test(20,0);
  function test($x,$z)
  {
    echo $x/$z;
  }
?>

Expected result:
----------------
#0  errorhandler(2, Division by zero, /home/iblue/public_html/the_engine/index.php, 8) called at [/home/iblue/public_html/the_engine/index.php:8]
#1  test(20, 0) called at [/home/iblue/public_html/the_engine/index.php:6]


Actual result:
--------------
#0  errorhandler() called at [/home/iblue/public_html/the_engine/index.php:8]
#1  test() called at [/home/iblue/public_html/the_engine/index.php:8]
#2  test(2, Division by zero, /home/iblue/public_html/the_engine/index.php, 8, Array ([x] => 20,[z] => 0)) called at [/home/iblue/public_html/the_engine/index.php:6]



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-12 23:08 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-08-12 23:33 UTC] iblue at gmx dot net
iblue@neandertal:~/php5-200508122030$ ./sapi/cli/php -q ~/public_html/bug.php
#0  errorhandler(2, Division by zero, /home/iblue/public_html/the_engine/index.php, 8, Array ([x] => 20,[z] => 0)) called at [/home/iblue/public_html/the_engine/index.php:8]
#1  test(20, 0) called at [/home/iblue/public_html/the_engine/index.php:6]

better, but not right ;)
 [2005-08-12 23:39 UTC] tony2001@php.net
I can't find any differencies between the expected result and what you've just posted.
 [2005-08-12 23:45 UTC] iblue at gmx dot net
The difference is
Array ([x] => 20,[z] =>0)

Actual result:
#0  errorhandler(2, Division by zero,
/home/iblue/public_html/the_engine/index.php, 8, Array ([x] => 20,[z] =>
0)) called at [/home/iblue/public_html/the_engine/index.php:8]

Expected result:
#0  errorhandler(2, Division by zero,
/home/iblue/public_html/the_engine/index.php, 8) called at
[/home/iblue/public_html/the_engine/index.php:8]
#1  test(20, 0) called at
[/home/iblue/public_html/the_engine/index.php:6]

Do you see the addictional arguments in #0 after "...index.php, 8"?

Seen it?
 [2005-08-13 00:14 UTC] tony2001@php.net
This is expected:

"The fifth parameter is optional, errcontext , which is an array that points to the active symbol table at the point the error occurred. In other words, errcontext will contain an array of every variable that existed in the scope the error was triggered in."
(c) http://www.php.net/set_error_handler
 [2005-08-13 00:27 UTC] iblue at gmx dot net
My errorhandler()-function only uses 4 parameters, but 5 printed, this is a bug.
 [2005-08-13 00:31 UTC] tony2001@php.net
Your error function *ACCEPTS* only 4 arguments, but 5 of them are passed.
No bug here, this is expected and documented behaviour.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 29 20:00:03 2025 UTC