|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-06-07 10:48 UTC] tyrael@php.net
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" } } } Patchesadd_call_proxy_flag.patch (last revision 2013-06-09 09:00 UTC by laruence@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 04:00:01 2025 UTC |
it seems that the xdebug debug backtrace works the same way as it was proposed here: Call Stack: 0.0016 639496 1. {main}() test.php:0 0.0026 639624 2. call_user_func() test.php:9 0.0026 639624 3. foo() test.php:9 0.0026 639624 4. bar() test.php:3 0.0026 639800 5. trigger_error() test.php:7 notice that it lists both the call_user_func() and the foo() call, both of the pointing to the same file:linehmm, I may find a solution, use tricky ZEND_CALL_VIA_HANDLER fn_flags, for call_user_func, may like: $ git diff diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 9c91404..03f836e 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2983,7 +2983,7 @@ const zend_function_entry basic_functions[] = { /* {{{ */ PHP_FE(error_log, arginfo_error_log) PHP_FE(error_get_last, arginfo_error_get_last) - PHP_FE(call_user_func, arginfo_call_user_func) + ZEND_FENTRY(call_user_func, ZEND_FN(call_user_func), arginfo_call_user_func, ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_ PUBLIC) PHP_FE(call_user_func_array, arginfo_call_user_func_array) PHP_DEP_FE(call_user_method, arginfo_call_user_method) PHP_DEP_FE(call_user_method_array, arginfo_call_user_method_array)