Bug #64987 [NEW]: unexpected result for call_user_func() in the debug_backtrace()
From: tyrael
Operating system: irrelevant
PHP version: 5.3.26
Package: Scripting Engine problem
Bug Type: Bug
Bug description:unexpected result for call_user_func() in the debug_backtrace()
Description:
------------
call_user_func() generates two entry to the backtrace: one for the call of
the
call_user_func with the callable arg and one for the call of the callable.
the problem is that the entry only has function and args entry, but no file
or
line.
This happens because the execution reaches the break here:
http://lxr.php.net/xref/PHP_5_3/Zend/zend_builtin_functions.c#2161
Which based on the comment above is there to prevent touching the stack
when we
are inside the error handler, which isn't the case here.
When discussing this with Nikita on irc he said that we shouldn't have two
entry
in the result in the first place for call_user_func, but I think that
removing
one entry would have bigger impact on userland (there is a chance that some
people already remove the entry manually and this change would make it
remove o
valid entry) compared to the change to fill out the information that was
ommited
before.
btw it seems that the suggested behavior was present between 5.0.0 and
5.0.5:
http://3v4l.org/jI9VI#v430
5.0.5 had two debug_backtrace related fix mentioned in the changelog(#30828
and
#28377) but from a quick glance on the description it seems to be
irrelevant
from this behavior change.
In case if we decide to not change the current behavior, please turn this
report
into a documentation problem as it would be nice if the docs would reflect
what
information will present (or missing) in which case.
Currently we only hint that the type and args can be missing in some case.
ps: the issue is still present in master and commenting out the if with
that
break produces the expected result but ofc. that isn't the proper fix.
Test script:
---------------
<?php
function foo() {
var_dump(bar());
}
function bar() {
return debug_backtrace();
}
call_user_func("foo");
Expected result:
----------------
array(3) {
[0]=>
array(4) {
["file"]=>
string(9) "/in/jI9VI"
["line"]=>
int(3)
["function"]=>
string(3) "bar"
["args"]=>
array(0) {
}
}
[1]=>
array(4) {
["file"]=>
string(9) "/in/jI9VI"
["line"]=>
int(8)
["function"]=>
string(3) "foo"
["args"]=>
array(0) {
}
}
[2]=>
array(4) {
["file"]=>
string(9) "/in/jI9VI"
["line"]=>
int(8)
["function"]=>
string(14) "call_user_func"
["args"]=>
array(1) {
[0]=>
&string(3) "foo"
}
}
}
Actual result:
--------------
array(3) {
[0]=>
array(4) {
["file"]=>
string(9) "/in/jI9VI"
["line"]=>
int(3)
["function"]=>
string(3) "bar"
["args"]=>
array(0) {
}
}
[1]=>
array(2) {
["function"]=>
string(3) "foo"
["args"]=>
array(0) {
}
}
[2]=>
array(4) {
["file"]=>
string(9) "/in/jI9VI"
["line"]=>
int(8)
["function"]=>
string(14) "call_user_func"
["args"]=>
array(1) {
[0]=>
&string(3) "foo"
}
}
}
--
Edit bug report at https://bugs.php.net/bug.php?id=64987&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64987&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64987&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64987&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64987&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64987&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64987&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64987&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64987&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64987&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64987&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=64987&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=64987&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64987&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64987&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64987&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64987&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64987&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64987&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64987&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64987&r=mysqlcfg
Thread (13 messages)
- tyrael@php.net
- tyrael@php.netBug #64987 [Opn]: unexpected result for call_user_func() in the debug_backtrace()
- dmitry@php.netBug #64987 [Opn->Asn]: unexpected result for call_user_func() in the debug_backtrace()
- tyrael@php.netBug #64987 [Asn]: unexpected result for call_user_func() in the debug_backtrace()
- nikic@php.netBug #64987 [Com]: unexpected result for call_user_func() in the debug_backtrace()
- tyrael@php.netBug #64987 [Asn]: unexpected result for call_user_func() in the debug_backtrace()
- laruence@php.netBug #64987 [Asn]: unexpected result for call_user_func() in the debug_backtrace()
- laruence@php.netBug #64987 [Asn]: unexpected result for call_user_func() in the debug_backtrace()
- laruence@php.netBug #64987 [PATCH]: unexpected result for call_user_func() in the debug_backtrace()
- laruence@php.netBug #64987 [Asn]: unexpected result for call_user_func() in the debug_backtrace()
- dmitry@php.netBug #64987 [Asn]: unexpected result for call_user_func() in the debug_backtrace()
- kalle@php.netBug #64987 [Asn->Opn]: unexpected result for call_user_func() in the debug_backtrace()
- requinix@php.netBug #64987 [Opn->Csd]: unexpected result for call_user_func() in the debug_backtrace()