php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28377 debug_backtrace is intermittently passing args
Submitted: 2004-05-12 20:43 UTC Modified: 2005-06-23 14:22 UTC
Votes:4
Avg. Score:4.8 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:2 (50.0%)
From: sean at caedmon dot net Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS, 4CVS (2005-06-19) OS: *
Private report: No CVE-ID: None
 [2004-05-12 20:43 UTC] sean at caedmon dot net
Description:
------------
debug_backtrace() behaves strangely when passed as a function argument.

This does not happen if debug_backtrace is dereferenced (see code), nor if debug_backtrace() is the first parameter to my custom_callback function (not denoted in code)

I'll be happy to provide additional details.

This SEEMS like #27397 but is not a ZE2 problem (I'm using 4.3) and is NOT fixed in CVS.

Thanks,
S


Reproduce code:
---------------
<?php
function doit($a, $b)
{
  $trace = debug_backtrace();
  custom_callback('dereferenced', $trace);
  custom_callback('direct', debug_backtrace());
}
  
function custom_callback($traceName, $btInfo)
{
  echo $traceName ." -- args: ";
  echo isset($btInfo[0]['args']) ? 'exists' : 'does not exist';
  echo "\n";
}
  
doit('a','b');

?>


Expected result:
----------------
dereferenced -- args: exists
direct -- args: exists


Actual result:
--------------
dereferenced -- args: exists
direct -- args: does not exist


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-15 11:45 UTC] aidan@php.net
debug_backtrace loses information in subsequent movements up the stack.

Simple test script:
<?php
function a() {
    b();
}

function b() {
    c('foo', 'bar');
}

function c($a, $b){
    print_r(debug_backtrace());
    d();
}

function d() {
    print_r(debug_backtrace());
}

a();
?>

This block should be present in both backtraces:

            [function] => c
            [args] => Array
                (
                    [0] => foo
                    [1] => bar
                )

In the second backtrace, it is not:

            [function] => c
            [args] => Array
                (
                )

This problem does not, as one might expect, propogate to debug_print_backtrace.
 [2005-06-23 14:22 UTC] dmitry@php.net
Fixed in CVS HEAD, PHP_5_0 and PHP_4_4.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 13:01:29 2024 UTC