Bug #70188 [NEW]: debug_backtrace + register_tick_function do not always work

From: Date: Mon, 03 Aug 2015 12:11:36 +0000
Subject: Bug #70188 [NEW]: debug_backtrace + register_tick_function do not always work
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194930@lists.php.net to get a copy of this message
From:             emilio dot pinn at gmail dot com
Operating system: Ubuntu
PHP version:      Irrelevant
Package:          *General Issues
Bug Type:         Bug
Bug description:debug_backtrace + register_tick_function do not always work

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 bug report at https://bugs.php.net/bug.php?id=70188&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=70188&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=70188&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=70188&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=70188&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=70188&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=70188&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=70188&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=70188&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=70188&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=70188&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=70188&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=70188&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=70188&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70188&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=70188&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=70188&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=70188&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70188&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=70188&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=70188&r=mysqlcfg



Thread (8 messages)

« previous php.bugs (#194930) next »