Mantis - Quercus
Viewing Issue Advanced Details
3611 minor always 07-27-09 10:43 07-27-09 10:47
tlandmann  
 
normal  
new 4.0.0  
open  
none    
none  
0003611: Call Stack getting broken (apparently)
The script below prints an impossible result in Quercus:
Suddenly the bottom of the call stack (invocation of some_function() from the end of the script) is gone.

However it seems that the bug is only limited to debug_backtrace(), so there're no negative effect on programs that don't rely on this PHP function.

I didn't prove that though.


--------------------

<?php

function dump_trace()
{
    foreach (debug_backtrace() as $cur_stack_element)
    {
        echo "# {$cur_stack_element['function']}() from {$cur_stack_element['file']}:{$cur_stack_element['line']}\n";
    }
    echo "\n";
}

function some_function($depth=0, $max_depth=5)
{
    if ($depth<$max_depth)
    {
        dump_trace();
        
        if ($depth==2)
        {
            $function_name='some_function';
            $function_name($depth+1, $max_depth); // this syntax, although valid PHP, causes the problem
        }
        else
        {
            some_function($depth+1, $max_depth); // works
            // call_user_func_array($function_name, array($depth+1, $max_depth)); // may also want to try this one -> it also works
        }
    }
}

some_function();

dump_trace();

?>

----------------

Notes
(0004101)
tlandmann   
07-27-09 10:47   
sample output of the script running in Quercus:

------------------------

# dump_trace() from test2.php:16
# some_function() from test2.php:31

# dump_trace() from test2.php:16
# some_function() from test2.php:25
# some_function() from test2.php:31

# dump_trace() from test2.php:16
# some_function() from test2.php:25
# some_function() from test2.php:25
# some_function() from test2.php:31

# dump_trace() from test2.php:16
# some_function() from test2.php:25
# some_function() from test2.php:25

# dump_trace() from test2.php:16
# some_function() from test2.php:25
# some_function() from test2.php:25
# some_function() from test2.php:25

# dump_trace() from test2.php:33

------------------------

output from standard PHP 5.2.6:

------------------------

# dump_trace() from test2.php:16
# some_function() from test2.php:31

# dump_trace() from test2.php:16
# some_function() from test2.php:25
# some_function() from test2.php:31

# dump_trace() from test2.php:16
# some_function() from test2.php:25
# some_function() from test2.php:25
# some_function() from test2.php:31

# dump_trace() from test2.php:16
# some_function() from test2.php:21
# some_function() from test2.php:25
# some_function() from test2.php:25
# some_function() from test2.php:31

# dump_trace() from test2.php:16
# some_function() from test2.php:25
# some_function() from test2.php:21
# some_function() from test2.php:25
# some_function() from test2.php:25
# some_function() from test2.php:31

# dump_trace() from test2.php:33

------------------------