Bug #70188 [Asn->Opn]: debug_backtrace + register_tick_function do not always work

From: Date: Mon, 03 Aug 2015 16:58:54 +0000
Subject: Bug #70188 [Asn->Opn]: debug_backtrace + register_tick_function do not always work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194945@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70188&edit=1 ID: 70188 Updated by: cmb@php.net Reported by: emilio dot pinn at gmail dot com Summary: debug_backtrace + register_tick_function do not always work -Status: Assigned +Status: Open Type: Bug Package: *General Issues Operating System: Ubuntu PHP Version: Irrelevant -Assigned To: cmb +Assigned To: Block user comment: N Private report: N New Comment: I can't reproduce the described behavior with Joomla 3.4.3. A single request to the home page (front-end) causes a 1.5 MB log file to be generated, which contains 24652 FUNCTION NAME and only 14 NO BACKTRACE messages. Previous Comments: ------------------------------------------------------------------------ [2015-08-03 15:26:36] emilio dot pinn at gmail dot com Hello, The test script is already included in the bug ticket, you have just to include it at every requests done to a joomla installation e.g. using "php_value auto_prepend_file" option in its .htaccess file. Let me know if you need any further information. ------------------------------------------------------------------------ [2015-08-03 13:41:07] cmb@php.net On further consideration the behavior is somewhat strange. Anyhow, to properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2015-08-03 12:57:58] emilio dot pinn at gmail dot com Hi, thanks for your prompt response. The very strange behaviour is that in the conditions I described, debug_backtrace() returns just a single element backtrace, instead of the complete backtrace of any invoked functions. I can't understand why this strange behaviour. ------------------------------------------------------------------------ [2015-08-03 12:51:55] cmb@php.net Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. If there is only a single stack frame, debug_backtrace() is supposed to return an array with a single element. Change count($bt) <= 1 to count($bt) < 1 or empty($bt). ------------------------------------------------------------------------ [2015-08-03 12:11:36] emilio dot pinn at gmail dot com Description: ------------ The following simple profiling script does not work on certain codes, e.g. with the vanilla installation of Joomla v3.4.2. It works with other complex CMS e.g. with WordPress. To easily prepend the profiling PHP script to the application, I used php_value auto_prepend_file "/tmp/instrumentation.php" In the .htaccess in the web root. Then, paste the test script in "/tmp/instrumentation.php". The output you can see in "/var/log/apache2/error.log" is just a series of "NO BACKTRACE" strings. PHP version; PHP 5.5.9-1ubuntu4.11 (cli) (built: Jul 2 2015 15:23:08) Test script: --------------- <?php function printname() { $bt = debug_backtrace(); if (count($bt) <= 1) { error_log('NO BACKTRACE: ' . print_r($bt, true)); } else { error_log('FUNCTION NAME: ' . $bt[1]['function']); } } declare(ticks=1); register_tick_function('printname'); ?> Expected result: ---------------- I expect a result like the following when I open the "/var/log/apache2/error.log" [:error] [pid 9091] [client 127.0.0.1:55726] FUNCTION NAME: function1 [:error] [pid 9091] [client 127.0.0.1:55726] FUNCTION NAME: function2 [:error] [pid 9091] [client 127.0.0.1:55726] FUNCTION NAME: function3 [:error] [pid 9091] [client 127.0.0.1:55726] FUNCTION NAME: function4 ... As this happens using the same test script with other code. Actual result: -------------- [:error] [pid 7555] [client 127.0.0.1:55742] NO BACKTRACE: Array\n(\n [0] => Array\n (\n [file] => /tmp/instrumentation.php\n [line] => 14\n [function] => printname\n [args] => Array\n (\n )\n\n )\n\n) [:error] [pid 7555] [client 127.0.0.1:55742] NO BACKTRACE: Array\n(\n [0] => Array\n (\n [file] => /tmp/instrumentation.php\n [line] => 16\n [function] => printname\n [args] => Array\n (\n )\n\n )\n\n) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70188&edit=1

« previous php.bugs (#194945) next »