#42058 [Fbk->Opn]: debug_backtrace messes up with references

From: Date: Mon, 23 Jul 2007 12:40:46 +0000
Subject: #42058 [Fbk->Opn]: debug_backtrace messes up with references
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115352@lists.php.net to get a copy of this message
ID: 42058 User updated by: mcorne at yahoo dot com Reported By: mcorne at yahoo dot com -Status: Feedback +Status: Open Bug Type: Scripting Engine problem Operating System: Windows XP PHP Version: 5.2.3 New Comment: I used http://snaps.php.net/win32/php5.2-win32-latest.zip as you recommended: PHP Version => 5.2.4-dev. I get the same error. Previous Comments: ------------------------------------------------------------------------ [2007-07-21 13:08:08] jani@php.net 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 ------------------------------------------------------------------------ [2007-07-21 09:40:59] mcorne at yahoo dot com Description: ------------ error #1: debug_backtrace() does not report the original value of a variable passed by reference even if it is called before the variable is modified. error #2: debug_backtrace() messes up with the content of an array used to store debug_backtrace() results from subsequent calls to the same function. Reproduce code: --------------- <?php function trace() { global $trace; $trace[] = debug_backtrace(); } function foo(&$pos) { trace(); $pos++; } $pos = 0; foo($pos); echo "error #1\n----------\n"; var_export($trace); echo "\n\nerror #2\n----------\n"; foo($pos); var_export($trace); ?> Expected result: ---------------- error #1 ---------- array ( 0 => array ( 0 => array ( 'file' => 'D:\\Data\\dev\\i18n-unicodnorm\\trunk\\I18N\\tests\\bug.php', 'line' => 11, 'function' => 'trace', 'args' => array ( ), ), 1 => array ( 'file' => 'D:\\Data\\dev\\i18n-unicodnorm\\trunk\\I18N\\tests\\bug.php', 'line' => 16, 'function' => 'foo', 'args' => array ( 0 => 0, ), ), ), ) error #2 ---------- array ( 0 => array ( 0 => array ( 'file' => 'D:\\Data\\dev\\i18n-unicodnorm\\trunk\\I18N\\tests\\bug.php', 'line' => 11, 'function' => 'trace', 'args' => array ( ), ), 1 => array ( 'file' => 'D:\\Data\\dev\\i18n-unicodnorm\\trunk\\I18N\\tests\\bug.php', 'line' => 16, 'function' => 'foo', 'args' => array ( 0 => 0, ), ), ), 1 => array ( 0 => array ( 'file' => 'D:\\Data\\dev\\i18n-unicodnorm\\trunk\\I18N\\tests\\bug.php', 'line' => 11, 'function' => 'trace', 'args' => array ( ), ), 1 => array ( 'file' => 'D:\\Data\\dev\\i18n-unicodnorm\\trunk\\I18N\\tests\\bug.php', 'line' => 20, 'function' => 'foo', 'args' => array ( 0 => 1, ), ), ), ) Actual result: -------------- error #1 ---------- array ( 0 => array ( 0 => array ( 'file' => 'D:\\Data\\dev\\i18n-unicodnorm\\trunk\\I18N\\tests\\bug.php', 'line' => 11, 'function' => 'trace', 'args' => array ( ), ), 1 => array ( 'file' => 'D:\\Data\\dev\\i18n-unicodnorm\\trunk\\I18N\\tests\\bug.php', 'line' => 16, 'function' => 'foo', 'args' => array ( 0 => 1, ), ), ), ) error #2 ---------- array ( 0 => array ( 0 => array ( 'file' => 'D:\\Data\\dev\\i18n-unicodnorm\\trunk\\I18N\\tests\\bug.php', 'line' => 11, 'function' => 'trace', 'args' => array ( ), ), 1 => array ( 'file' => 'D:\\Data\\dev\\i18n-unicodnorm\\trunk\\I18N\\tests\\bug.php', 'line' => 16, 'function' => 'foo', 'args' => array ( 0 => 2, ), ), ), 1 => array ( 0 => array ( 'file' => 'D:\\Data\\dev\\i18n-unicodnorm\\trunk\\I18N\\tests\\bug.php', 'line' => 11, 'function' => 'trace', 'args' => array ( ), ), 1 => array ( 'file' => 'D:\\Data\\dev\\i18n-unicodnorm\\trunk\\I18N\\tests\\bug.php', 'line' => 20, 'function' => 'foo', 'args' => array ( 0 => 2, ), ), ), ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42058&edit=1

« previous php.bugs (#115352) next »