xhprof for PHP7

Overview

xhprof for PHP7

Build Status Build status

XHProf is a function-level hierarchical profiler for PHP and has a simple HTML based navigational interface. The raw data collection component is implemented in C (as a PHP extension). The reporting/UI layer is all in PHP. It is capable of reporting function-level inclusive and exclusive wall times, memory usage, CPU times and number of calls for each function. Additionally, it supports ability to compare two runs (hierarchical DIFF reports), or aggregate results from multiple runs.

This version supports PHP7

PHP Version

  • 7.0
  • 7.1
  • 7.2
  • 7.3
  • 7.4
  • 8.0

Installation

git clone https://github.com/longxinH/xhprof.git ./xhprof
cd xhprof/extension/
/path/to/php7/bin/phpize
./configure --with-php-config=/path/to/php7/bin/php-config
make && sudo make install

configuration add to your php.ini

[xhprof]
extension = xhprof.so
xhprof.output_dir = /tmp/xhprof

php.ini configuration

    Options       Defaults Version Explain
xhprof.output_dir   "" All Output directory
xhprof.sampling_interval   100000 >= v2.* Sampling interval to be used by the sampling profiler, in microseconds
xhprof.sampling_depth   INT_MAX >= v2.* Depth to trace call-chain by the sampling profiler
xhprof.collect_additional_info   0 >= v2.1 Collect mysql_query, curl_exec internal info. The default is 0. Open value is 1

Turn on extra collection

php.ini adds xhprof.collect_additional_info

xhprof.collect_additional_info = 1

Options

xhprof_enable(XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
  • XHPROF_FLAGS_NO_BUILTINS do not profile builtins
  • XHPROF_FLAGS_CPU gather CPU times for funcs
  • XHPROF_FLAGS_MEMORY gather memory usage for funcs

Example

array( "wt" => 237, "ct" => 1, "cpu" => 100, ) )">


array(
    "main()" => array(
        "wt" => 237,
        "ct" => 1,
        "cpu" => 100,
    )
)
  • wt The execution time of the function method is time consuming
  • ct The number of times the function was called
  • cpu The CPU time consumed by the function method execution
  • mu Memory used by function methods. The call is zend_memory_usage to get the memory usage
  • pmu Peak memory used by the function method. The call is zend_memory_peak_usage to get the memory

PDO::exec

PDO::query

mysqli_query

query("SELECT * FROM user LIMIT 10");">
$mysqli = new mysqli("localhost", "my_user", "my_password", "user");
$result = $mysqli->query("SELECT * FROM user LIMIT 10");
Output data
mysqli::query#SELECT * FROM user LIMIT 10

PDO::prepare

Convert preprocessing placeholders for actual parameters, more intuitive analytic performance (does not change the zend execution process)

execute([':id' => '1', ':name' => 'admin']); $data1 = $_sth->fetch(); $_sth = $db->prepare("SELECT * FROM user where userid = ?"); $_sth->execute([1]); $data2 = $_sth->fetch();">
$_sth = $db->prepare("SELECT * FROM user where userid = :id and username = :name");
$_sth->execute([':id' => '1', ':name' => 'admin']);
$data1 = $_sth->fetch();

$_sth = $db->prepare("SELECT * FROM user where userid = ?");
$_sth->execute([1]);
$data2 = $_sth->fetch();
Output data
PDOStatement::execute#SELECT * FROM user where userid = 1 and username = admin
PDOStatement::execute#SELECT * FROM user where userid = 1

Curl

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.baidu.com");
$output = curl_exec($ch);
curl_close($ch);
Output data
curl_exec#http://www.baidu.com

PECL Repository

pecl

Comments
  • Test xhprof_008.phpt fails on s390x

    Test xhprof_008.phpt fails on s390x

    I have no such hardware to make sure why it fails but Alpinelinux build system reported

    FAILED TEST SUMMARY
    ---------------------------------------------------------------------
    XHProf: Sampling Mode Test
    Author: kannan [tests/xhprof_008.phpt]
    

    Current log http://build.alpinelinux.org/buildlogs/build-edge-s390x/testing/php7-xhprof/php7-xhprof-2.0.2-r0.log

    opened by andypost 32
  • PHP 8 jit + xhprof

    PHP 8 jit + xhprof

    Just used to try use Drupal 9-dev using JIT and the extension

    # php -dopcache.jit_buffer_size=10M -dextension=xhprof -S 0.0.0.0:44543 .ht.router.php 
    [Fri Nov 27 14:04:39 2020] PHP 8.0.0 Development Server (http://0.0.0.0:44543) started
    [Fri Nov 27 14:04:44 2020] 172.16.0.1:46404 Accepted
    Segmentation fault (core dumped)
    

    PS: using latest build packages from Alpinelinux (will check official docker images when they out)

    opened by andypost 21
  • hp_get_function_stack crash

    hp_get_function_stack crash

    0x00000000005e8b74 in ?? () #1 0x00000000005b0f57 in ?? () #2 0x000000000061056c in zend_vspprintf () #3 0x00000000006106b3 in zend_spprintf () #4 0x00007f8d4c0a4047 in hp_get_function_stack (entry=entry@entry=0x1e0e340, level=level@entry=2) at /root/xhprof_mysql/extension/xhprof.c:582 #5 0x00007f8d4c0a4195 in hp_mode_hier_endfn_cb (entries=) at /root/xhprof_mysql/extension/xhprof.c:1024 #6 0x00007f8d4c0a5503 in hp_execute_internal (execute_data=0x7f8d5241c500, return_value=0x7f8d5241c4d0) at /root/xhprof_mysql/extension/xhprof.c:1149 #7 0x000000000068a11b in ?? () #8 0x0000000000656838 in execute_ex () #9 0x00007f8d4c0a535e in hp_execute_ex (execute_data=0x7f8d5241c450) at /root/xhprof_mysql/extension/xhprof.c:1107 #10 0x0000000000601110 in zend_call_function () #11 0x000000000062f733 in zend_call_method () #12 0x000000000064beaa in ?? () #13 0x00000000006771f6 in ?? () #14 0x0000000000656838 in execute_ex () #15 0x00007f8d4c0a535e in hp_execute_ex (execute_data=0x7f8d5241c370) at /root/xhprof_mysql/extension/xhprof.c:1107 #16 0x000000000068a4b1 in ?? () #17 0x0000000000656838 in execute_ex () #18 0x00007f8d4c0a535e in hp_execute_ex (execute_data=0x7f8d5241c2e0) at /root/xhprof_mysql/extension/xhprof.c:1107 #19 0x000000000068a4b1 in ?? () #20 0x0000000000656838 in execute_ex () #21 0x00007f8d4c0a535e in hp_execute_ex (execute_data=0x7f8d5241c1d0) at /root/xhprof_mysql/extension/xhprof.c:1107 #22 0x000000000068a4b1 in ?? () #23 0x0000000000656838 in execute_ex () #24 0x00007f8d4c0a535e in hp_execute_ex (execute_data=0x7f8d5241c150) at /root/xhprof_mysql/extension/xhprof.c:1107 #25 0x000000000068a4b1 in ?? () #26 0x0000000000656838 in execute_ex () #27 0x00007f8d4c0a535e in hp_execute_ex (execute_data=0x7f8d5241c0c0) at /root/xhprof_mysql/extension/xhprof.c:1107 #28 0x000000000068a4b1 in ?? () #29 0x0000000000656838 in execute_ex () #30 0x00007f8d4c0a535e in hp_execute_ex (execute_data=0x7f8d5241c030) at /root/xhprof_mysql/extension/xhprof.c:1107 #31 0x0000000000601110 in zend_call_function () #32 0x0000000000601d67 in _call_user_function_ex () #33 0x000000000060ec15 in zend_try_exception_handler () #34 0x000000000060ed7f in zend_execute_scripts () #35 0x00000000005ac3f8 in php_execute_script () #36 0x00000000006c945e in ?? () #37 0x000000352561ed20 in __libc_start_main () from /lib64/libc.so.6 #38 0x000000000042b815 in _start ()

    opened by wjiacn 20
  • 3 tests failed

    3 tests failed

    The below 3 tests failed even though php.info is showing xhprof v 2.0.1 is enabled.

    I also have "php_admin_value auto_prepend_file /var/www/html/xhgui/external/header.php" in my apache vhost but unfortunately no profiling is happening. Pleas help.

    FAILED TEST SUMMARY
    ---------------------------------------------------------------------
    XHProf: Basic Profiling Test
    Author: Kannan [tests/xhprof_001.phpt]
    XHProf: Test Include File (load/run_init operations)
    Author: Kannan [tests/xhprof_004.phpt]
    XHProf: Test excluding call_user_func and similar functions
    Author: mpal [tests/xhprof_007.phpt]
    =========================================
    
    opened by markusd1984 16
  • 502 Bad Gateway sometimes

    502 Bad Gateway sometimes

    I added extension to docker image It cause 502 Error sometimes.

    php_1 | [10-Aug-2021 14:16:44] WARNING: [pool www] child 8 exited on signal 11 (SIGSEGV - core dumped) after 127.559666 seconds from start php_1 | [10-Aug-2021 14:16:44] NOTICE: [pool www] child 62 started http_1 | 2021/08/10 14:16:44 [error] 25#25: *3 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.48.1, server: localhost, request: "POST /auth/token?w HTTP/1.1", upstream: "fastcgi://192.168.48.4:9000", host: "127.0.0.2"

    I tried it with php8 and php7.4

    opened by koekaverna 15
  • Tests fail on PHP 8.2.0 beta3 and RC1

    Tests fail on PHP 8.2.0 beta3 and RC1

    Bug Report

    Please answer these questions before submitting your issue. Thanks!

    1. What did you do? If possible, provide a simple script for reproducing the error. rebuilding against PHP 8.2.0RC1 as API changed

    2. What did you expect to see? tests pass

    3. What did you see instead lots of failed tests

    4. What is your Xhprof version? 2.3.5

    bug 
    opened by andypost 10
  • bug?

    bug?

    具体现象是:php-fpm打印出所有请求相应时间都很慢,导致服务器无法正常相应,只能通过重启php-fpm来解决。

    系统环境:

    xhprof
    
    xhprof => 1.0.0
    CPU num => 32
    
    apcu
    
    APCu Support => Disabled
    Version => 5.1.8
    APCu Debugging => Disabled
    MMAP Support => Enabled
    MMAP File Mask =>
    Serialization Support => Disabled
    Build Date => Oct 17 2017 19:49:16
    
    php: PHP 7.1.10
    

    gdb打印的调用栈:

    #0  0x00000036a620ac50 in pthread_rwlock_wrlock () from /lib64/libpthread.so.0
    #1  0x00007ffb746ae1d9 in apc_lock_wlock (lock=<value optimized out>) at /usr/local/src/apcu-5.1.8/apc_lock.c:245
    #2  0x00007ffb746b231c in apc_cache_insert (cache=0x1e6d030, key=0x7fffa9b42b70, value=0x7ffb72377e78, ctxt=0x7fffa9b42b10, t=1523733237, exclusive=1 '\001') at /usr/local/src/apcu-5.1.8/apc_cache.c:948
    #3  0x00007ffb746b27ec in apc_cache_store (cache=0x1e6d030, strkey=0x7ffb7ab563f0, val=0x7ffb7aa14c00, ttl=0, exclusive=1 '\001') at /usr/local/src/apcu-5.1.8/apc_cache.c:552
    #4  0x00007ffb746af430 in apc_store_helper (execute_data=<value optimized out>, return_value=0x7fffa9b42cb0, exclusive=1 '\001') at /usr/local/src/apcu-5.1.8/php_apc.c:495
    #5  0x00007ffb72c25ba1 in hp_execute_internal (execute_data=0x7ffb7aa14ba0, return_value=0x7fffa9b42cb0) at /usr/local/src/xhprof-master/extension/xhprof.c:1776
    #6  0x00000000008d5dff in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER (execute_data=0x7ffb7aa14b00) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:972
    #7  0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #8  0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14b00) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #9  0x00000000008d567c in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER (execute_data=0x7ffb7aa14a70) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:1076
    #10 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #11 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14a70) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #12 0x000000000083ec1f in zend_call_function (fci=0x7fffa9b42f20, fci_cache=0x7fffa9b42f60) at /usr/local/src/php-7.1.10/Zend/zend_execute_API.c:855
    #13 0x00000000008719aa in zend_call_method (object=0x7ffb7aa62758, obj_ce=<value optimized out>, fn_proxy=<value optimized out>, function_name=0x7ffb7aa02928 "composer\\autoload\\classloader::loadclass\004", function_name_len=44,
        retval_ptr=0x0, param_count=1, arg1=0x7ffb7aa14a60, arg2=0x0) at /usr/local/src/php-7.1.10/Zend/zend_interfaces.c:99
    #14 0x00000000006ecfb4 in zif_spl_autoload_call (execute_data=<value optimized out>, return_value=<value optimized out>) at /usr/local/src/php-7.1.10/ext/spl/php_spl.c:420
    #15 0x00007ffb72c25ba1 in hp_execute_internal (execute_data=0x7ffb7aa14a10, return_value=0x7fffa9b43250) at /usr/local/src/xhprof-master/extension/xhprof.c:1776
    #16 0x000000000083f20b in zend_call_function (fci=0x7fffa9b431e0, fci_cache=0x7fffa9b43220) at /usr/local/src/php-7.1.10/Zend/zend_execute_API.c:871
    #17 0x000000000083f599 in zend_lookup_class_ex (name=<value optimized out>, key=0x7ffb69315ce0, use_autoload=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_execute_API.c:1028
    #18 0x000000000083f896 in zend_fetch_class_by_name (class_name=0x7ffb69316288, key=<value optimized out>, fetch_type=512) at /usr/local/src/php-7.1.10/Zend/zend_execute_API.c:1463
    #19 0x00000000008ead0a in ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER (execute_data=0x7ffb7aa14920) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:5479
    #20 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #21 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14920) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #22 0x00000000008f5695 in ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER (execute_data=0x7ffb7aa148d0) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:3479
    #23 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #24 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa148d0) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #25 0x00000000008f527c in ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER (execute_data=0x7ffb7aa147d0) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:51699
    #26 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #27 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa147d0) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #28 0x00000000008d567c in ZEND_DO_FCALL_SPEC_RETVAL_USED_HANDLER (execute_data=0x7ffb7aa14750) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:1076
    #29 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #30 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14750) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #31 0x00000000008f527c in ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER (execute_data=0x7ffb7aa146e0) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:51699
    #32 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #33 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa146e0) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #34 0x00000000008f527c in ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER (execute_data=0x7ffb7aa14670) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:51699
    #35 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #36 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14670) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #37 0x00000000008f527c in ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER (execute_data=0x7ffb7aa14600) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:51699
    #38 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #39 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14600) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #40 0x00000000008f527c in ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER (execute_data=0x7ffb7aa14590) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:51699
    #41 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #42 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14590) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #43 0x00000000008f527c in ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER (execute_data=0x7ffb7aa14520) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:51699
    #44 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #45 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14520) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #46 0x00000000008f527c in ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER (execute_data=0x7ffb7aa144b0) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:51699
    #47 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #48 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa144b0) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #49 0x00000000008f527c in ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER (execute_data=0x7ffb7aa14440) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:51699
    #50 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #51 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14440) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #52 0x00000000008f527c in ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER (execute_data=0x7ffb7aa143d0) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:51699
    #53 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #54 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa143d0) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #55 0x00000000008f527c in ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER (execute_data=0x7ffb7aa14360) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:51699
    #56 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #57 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14360) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #58 0x00000000008f5695 in ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER (execute_data=0x7ffb7aa14300) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:3479
    #59 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #60 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14300) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #61 0x00000000008f527c in ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER (execute_data=0x7ffb7aa14360) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:51699
    #62 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #63 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14360) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #64 0x00000000008f5695 in ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER (execute_data=0x7ffb7aa14300) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:3479
    #65 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #66 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14300) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #67 0x00000000008f527c in ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER (execute_data=0x7ffb7aa14210) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:51699
    #68 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #69 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14210) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #70 0x00000000008d5c87 in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER (execute_data=0x7ffb7aa14160) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:949
    #71 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #72 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14160) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #73 0x00000000008d5c87 in ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER (execute_data=0x7ffb7aa140a0) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:949
    #74 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #75 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa140a0) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #76 0x00000000008f527c in ZEND_INCLUDE_OR_EVAL_SPEC_TMPVAR_HANDLER (execute_data=0x7ffb7aa14030) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:51699
    #77 0x00000000008b1e38 in execute_ex (ex=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:432
    #78 0x00007ffb72c273a1 in hp_execute_ex (execute_data=0x7ffb7aa14030) at /usr/local/src/xhprof-master/extension/xhprof.c:1749
    #79 0x0000000000904bc5 in zend_execute (op_array=<value optimized out>, return_value=<value optimized out>) at /usr/local/src/php-7.1.10/Zend/zend_vm_execute.h:474
    #80 0x000000000084e734 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/local/src/php-7.1.10/Zend/zend.c:1480
    #81 0x00000000007daf00 in php_execute_script (primary_file=0x7fffa9b46710) at /usr/local/src/php-7.1.10/main/main.c:2552
    #82 0x000000000091255e in main (argc=<value optimized out>, argv=<value optimized out>) at /usr/local/src/php-7.1.10/sapi/fpm/fpm/fpm_main.c:1966
    
    opened by lichunqiang 9
  • SEGV with xhprof 2.3.8 enabled, php8.1 and php8.2

    SEGV with xhprof 2.3.8 enabled, php8.1 and php8.2

    Bug Report

    Please answer these questions before submitting your issue. Thanks!

    1. What did you do? If possible, provide a simple script for reproducing the error.

    Automated tests in DDEV seem to show that enabling xhprof 2.3.8 (PHP 8.1 and 8.2 only, using deb.sury.org package 2.3.8+0.9.4-1+0~20221209.18+debian11~1.gbp8f76ce) is causing

    url: (92) HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR (err 2)

    Logs show that this is a SEGV.

    To recreate, a junk.php in the docroot with

    <?php
    phpinfo();
    

    And hit http:///junk.php

    On PHP8.0 there is no SEGV, but on PHP8.1 and 8.2 there is not. (And this did not fail with xhprof 2.3.5). Linux/arm64, but happening in other contexts as well.

    core.1670789386.php-fpm.3373: ELF 64-bit LSB core file, ARM aarch64, version 1 (SYSV), SVR4-style, from 'php-fpm: pool www', real uid: 1000, effective uid: 1000, real gid: 1000, effective gid: 1000, execfn: '/usr/sbin/php-fpm', platform: 'aarch64'

    gdb /usr/sbin/php-fpm8.2 core.1670789386.php-fpm.3373 
    GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
    Copyright (C) 2021 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    Type "show copying" and "show warranty" for details.
    This GDB was configured as "aarch64-linux-gnu".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <https://www.gnu.org/software/gdb/bugs/>.
    Find the GDB manual and other documentation resources online at:
        <http://www.gnu.org/software/gdb/documentation/>.
    
    For help, type "help".
    Type "apropos word" to search for commands related to "word"...
    Reading symbols from /usr/sbin/php-fpm8.2...
    (No debugging symbols found in /usr/sbin/php-fpm8.2)
    
    warning: Can't open file /dev/zero (deleted) during file-backed mapping note processing
    [New LWP 3373]
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
    Core was generated by `php-fpm: pool www                                                    '.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0  0x0000aaaab4471e00 in php_stream_notification_free ()
    (gdb) bt
    #0  0x0000aaaab4471e00 in php_stream_notification_free ()
    #1  0x0000aaaab4471e44 in php_stream_context_free ()
    #2  0x0000aaaab44d9d78 in ?? ()
    #3  0x0000aaaab44da3cc in ?? ()
    #4  0x0000aaaab44afea0 in zend_shutdown_executor_values ()
    #5  0x0000aaaab44aff5c in ?? ()
    #6  0x0000aaaab44c1250 in zend_deactivate ()
    #7  0x0000aaaab445a0e4 in php_request_shutdown ()
    #8  0x0000aaaab42f120c in ?? ()
    #9  0x0000ffff881f1e18 in __libc_start_main () from /lib/aarch64-linux-gnu/libc.so.6
    #10 0x0000aaaab42f1d28 in _start ()
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)
    (gdb) 
    

    It does look like this might be related to the conversation in

    • https://github.com/longxinH/xhprof/pull/73

    I have verified that this happens on both amd64 and arm64 Debian Linux containers.

    1. What did you expect to see?

    Normal success

    1. What did you see instead

    SEGV from php-fpm.

    1. What is your Xhprof version?

    2.3.8 (2.3.5 did not cause this on PHP8.1)

    1. I created a demonstration repo so this might be easier to chase. I'm happy to help and improve it if you have any trouble.

    https://github.com/rfay/xhprof-bug-demo

    bug 
    opened by rfay 7
  • Segmentation fault with PHP 8.2.0RC4 and current xhprof master branch content

    Segmentation fault with PHP 8.2.0RC4 and current xhprof master branch content

    Bug Report

    1. Script to test
    <?php
    class SqlitePlatform
    {
        public static function udfSqrt($value)
        {
            return sqrt($value);
        }
    }
    
    $userDefinedFunctions = [
        'sqrt' => ['callback' => [SqlitePlatform::class, 'udfSqrt'], 'numArgs' => 1],
    ];
    
    $dsn = "sqlite:user-db.sqlite";
    try {
        $pdo = new PDO($dsn);
        foreach ($userDefinedFunctions as $fn => $data) {
            $pdo->sqliteCreateFunction($fn, $data['callback'], $data['numArgs']);
        }
        \var_dump($pdo);
    
    } catch (PDOException $e) {
        \var_dump($e);
    }
    
    1. What did you expect to see
    object(PDO)#1 (0) {
    }
    
    1. What did you see instead
    Segmentation fault
    
    1. What is your Xhprof version

    2.3.7 and current master branch too (commit a7befadae5b57bb63dff0cfaf05aa642e564aa03)

    I've though first that it was a PHP regression (see report https://github.com/php/php-src/issues/9749) until I found that it was this extension that run me in trouble.

    BTW, run version 2.3.7 run fine with PHP 8.2.0RC3 (no segmentation fault)

    bug 
    opened by llaville 7
  • macOS Catalina 10.15.1 and php 7.4 compile error

    macOS Catalina 10.15.1 and php 7.4 compile error

    Hello, After update on php 7.4 extension compile error:

    and1@and1pc:~/Desktop/xhprof/extension$ make
    /bin/sh /Users/and1/Desktop/xhprof/extension/libtool --mode=compile cc  -I. -I/Users/and1/Desktop/xhprof/extension -DPHP_ATOM_INC -I/Users/and1/Desktop/xhprof/extension/include -I/Users/and1/Desktop/xhprof/extension/main -I/Users/and1/Desktop/xhprof/extension -I/usr/local/Cellar/php/7.4.0/include/php -I/usr/local/Cellar/php/7.4.0/include/php/main -I/usr/local/Cellar/php/7.4.0/include/php/TSRM -I/usr/local/Cellar/php/7.4.0/include/php/Zend -I/usr/local/Cellar/php/7.4.0/include/php/ext -I/usr/local/Cellar/php/7.4.0/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /Users/and1/Desktop/xhprof/extension/xhprof.c -o xhprof.lo 
     cc -I. -I/Users/and1/Desktop/xhprof/extension -DPHP_ATOM_INC -I/Users/and1/Desktop/xhprof/extension/include -I/Users/and1/Desktop/xhprof/extension/main -I/Users/and1/Desktop/xhprof/extension -I/usr/local/Cellar/php/7.4.0/include/php -I/usr/local/Cellar/php/7.4.0/include/php/main -I/usr/local/Cellar/php/7.4.0/include/php/TSRM -I/usr/local/Cellar/php/7.4.0/include/php/Zend -I/usr/local/Cellar/php/7.4.0/include/php/ext -I/usr/local/Cellar/php/7.4.0/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /Users/and1/Desktop/xhprof/extension/xhprof.c  -fno-common -DPIC -o .libs/xhprof.o
    /Users/and1/Desktop/xhprof/extension/xhprof.c:361:10: error: expected ';' after expression
        ulong h = 5381;
             ^
             ;
    /Users/and1/Desktop/xhprof/extension/xhprof.c:361:5: error: use of undeclared identifier 'ulong'
        ulong h = 5381;
        ^
    /Users/and1/Desktop/xhprof/extension/xhprof.c:361:11: error: use of undeclared identifier 'h'
        ulong h = 5381;
              ^
    /Users/and1/Desktop/xhprof/extension/xhprof.c:366:9: error: use of undeclared identifier 'h'
            h += (h << 5);
            ^
    /Users/and1/Desktop/xhprof/extension/xhprof.c:366:15: error: use of undeclared identifier 'h'
            h += (h << 5);
                  ^
    /Users/and1/Desktop/xhprof/extension/xhprof.c:367:9: error: use of undeclared identifier 'h'
            h ^= (ulong) *str++;
            ^
    /Users/and1/Desktop/xhprof/extension/xhprof.c:367:15: error: use of undeclared identifier 'ulong'; did you
          mean 'long'?
            h ^= (ulong) *str++;
                  ^~~~~
                  long
    /Users/and1/Desktop/xhprof/extension/xhprof.c:367:14: error: reference to overloaded function could not be
          resolved; did you mean to call it?
            h ^= (ulong) *str++;
                 ^~~~~~~
    /Users/and1/Desktop/xhprof/extension/xhprof.c:370:28: error: use of undeclared identifier 'ulong'; did you
          mean 'long'?
        for (i = 0; i < sizeof(ulong); i++) {
                               ^~~~~
                               long
    /Users/and1/Desktop/xhprof/extension/xhprof.c:370:27: error: reference to overloaded function could not be
          resolved; did you mean to call it?
        for (i = 0; i < sizeof(ulong); i++) {
                              ^~~~~~~
    /Users/and1/Desktop/xhprof/extension/xhprof.c:371:27: error: use of undeclared identifier 'h'
            res += ((uint8 *)&h)[i];
                              ^
    /Users/and1/Desktop/xhprof/extension/xhprof.c:806:43: warning: format specifies type 'int' but the argument
          has type '__darwin_time_t' (aka 'long') [-Wformat]
        snprintf(key, sizeof(key), "%d.%06d", XHPROF_G(last_sample_time).tv_sec, XHPROF_G(last_sample_time...
                                    ~~        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                    %ld
    ./php_xhprof.h:309:21: note: expanded from macro 'XHPROF_G'
    #define XHPROF_G(v) (xhprof_globals.v)
                        ^
    /Users/and1/Desktop/xhprof/extension/xhprof.c:1443:101: error: too many arguments to function call, expected
          8, have 9
      ...0/* global */, 0/* ZEND_NUM_ARGS() >= 4 */, 0/*flags PREG_OFFSET_CAPTURE*/, 0/* start_offset */);
                                                                                     ^
    /usr/local/Cellar/php/7.4.0/include/php/ext/pcre/php_pcre.h:45:1: note: 'php_pcre_match_impl' declared here
    PHPAPI void  php_pcre_match_impl(pcre_cache_entry *pce, zend_string *subject_str, zval *return_value,
    ^
    /usr/local/Cellar/php/7.4.0/include/php/main/php.h:71:18: note: expanded from macro 'PHPAPI'
    #               define PHPAPI __attribute__ ((visibility("default")))
                                  ^
    /Users/and1/Desktop/xhprof/extension/xhprof.c:1600:13: warning: use of GNU old-style field designator
          extension [-Wgnu-designator]
                size: sizeof(zend_fcall_info),
                ^~~~~
                .size = 
    /Users/and1/Desktop/xhprof/extension/xhprof.c:1604:13: warning: use of GNU old-style field designator
          extension [-Wgnu-designator]
                function_name: func,
                ^~~~~~~~~~~~~~
                .function_name = 
    /Users/and1/Desktop/xhprof/extension/xhprof.c:1608:13: warning: use of GNU old-style field designator
          extension [-Wgnu-designator]
                retval: &retval,
                ^~~~~~~
                .retval = 
    /Users/and1/Desktop/xhprof/extension/xhprof.c:1609:13: warning: use of GNU old-style field designator
          extension [-Wgnu-designator]
                params: &params,
                ^~~~~~~
                .params = 
    /Users/and1/Desktop/xhprof/extension/xhprof.c:1610:13: warning: use of GNU old-style field designator
          extension [-Wgnu-designator]
                object: NULL,
                ^~~~~~~
                .object = 
    /Users/and1/Desktop/xhprof/extension/xhprof.c:1611:13: warning: use of GNU old-style field designator
          extension [-Wgnu-designator]
                no_separation: 1,
                ^~~~~~~~~~~~~~
                .no_separation = 
    /Users/and1/Desktop/xhprof/extension/xhprof.c:1612:13: warning: use of GNU old-style field designator
          extension [-Wgnu-designator]
                param_count: 1
                ^~~~~~~~~~~~
                .param_count = 
    /Users/and1/Desktop/xhprof/extension/xhprof.c:1609:21: warning: incompatible pointer types initializing
          'zval *' (aka 'struct _zval_struct *') with an expression of type 'zval (*)[1]'
          [-Wincompatible-pointer-types]
                params: &params,
                        ^~~~~~~
    9 warnings and 12 errors generated.
    make: *** [xhprof.lo] Error 1
    

    Any ideas how to fix? Thank you!

    opened by nohnaimer 7
  • 多版本php编译失败

    多版本php编译失败

    /usr/local/php/下是5.6 /usr/src/php-7.0.2/是7.0

    ## 操作步骤
     /usr/src/php-7.0.2/scripts/phpize
    PHP Api Version:         20131106
    Zend Module Api No:      20131226
    Zend Extension Api No:   220131226
    
    ./configure --with-php-config=/usr/src/php-7.0.2/scripts/php-config
    ...
    creating libtool
    appending configuration tag "CXX" to libtool
    configure: creating ./config.status
    config.status: creating config.h
    config.status: config.h is unchanged
    
    make
    ...
    :*** [xhprof.lo] Error 1 
    
    

    make详细记录

    /bin/sh /root/xhprof/extension/libtool --mode=compile cc  -I. -I/root/xhprof/extension -DPHP_ATOM_INC -I/root/xhprof/extension/include -I/root/xhprof/extension/main -I/root/xhprof/extension -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /root/xhprof/extension/xhprof.c -o xhprof.lo
    mkdir .libs
     cc -I. -I/root/xhprof/extension -DPHP_ATOM_INC -I/root/xhprof/extension/include -I/root/xhprof/extension/main -I/root/xhprof/extension -I/usr/local/php/include/php -I/usr/local/php/include/php/main -I/usr/local/php/include/php/TSRM -I/usr/local/php/include/php/Zend -I/usr/local/php/include/php/ext -I/usr/local/php/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/xhprof/extension/xhprof.c  -fPIC -DPIC -o .libs/xhprof.o
    /root/xhprof/extension/xhprof.c: In function ‘zm_startup_xhprof’:
    /root/xhprof/extension/xhprof.c:257:28: warning: assignment from incompatible pointer type [enabled by default]
         _zend_execute_internal = zend_execute_internal;
                                ^
    /root/xhprof/extension/xhprof.c:258:27: warning: assignment from incompatible pointer type [enabled by default]
         zend_execute_internal = hp_execute_internal;
                               ^
    /root/xhprof/extension/xhprof.c: In function ‘zm_shutdown_xhprof’:
    /root/xhprof/extension/xhprof.c:277:27: warning: assignment from incompatible pointer type [enabled by default]
         zend_execute_internal = _zend_execute_internal;
                               ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_init_profiler_state’:
    /root/xhprof/extension/xhprof.c:451:42: error: ‘IS_UNDEF’ undeclared (first use in this function)
         if (Z_TYPE(XHPROF_G(stats_count)) != IS_UNDEF) {
                                              ^
    /root/xhprof/extension/xhprof.c:451:42: note: each undeclared identifier is reported only once for each function it appears in
    /root/xhprof/extension/xhprof.c:452:9: warning: passing argument 1 of ‘_zval_ptr_dtor’ from incompatible pointer type [enabled by default]
             zval_ptr_dtor(&XHPROF_G(stats_count));
             ^
    In file included from /usr/local/php/include/php/Zend/zend.h:850:0,
                     from /usr/local/php/include/php/main/php.h:35,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_variables.h:51:15: note: expected ‘struct zval **’ but argument is of type ‘struct zval *’
     ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC);
                   ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_clean_profiler_state’:
    /root/xhprof/extension/xhprof.c:474:42: error: ‘IS_UNDEF’ undeclared (first use in this function)
         if (Z_TYPE(XHPROF_G(stats_count)) != IS_UNDEF) {
                                              ^
    /root/xhprof/extension/xhprof.c:475:9: warning: passing argument 1 of ‘_zval_ptr_dtor’ from incompatible pointer type [enabled by default]
             zval_ptr_dtor(&XHPROF_G(stats_count));
             ^
    In file included from /usr/local/php/include/php/Zend/zend.h:850:0,
                     from /usr/local/php/include/php/main/php.h:35,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_variables.h:51:15: note: expected ‘struct zval **’ but argument is of type ‘struct zval *’
     ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC);
                   ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_get_function_name’:
    /root/xhprof/extension/xhprof.c:631:5: error: unknown type name ‘zend_string’
         zend_string       *func = NULL;
         ^
    /root/xhprof/extension/xhprof.c:638:29: error: ‘zend_execute_data’ has no member named ‘func’
         curr_func = execute_data->func;
                                 ^
    /root/xhprof/extension/xhprof.c:640:10: warning: assignment from incompatible pointer type [enabled by default]
         func = curr_func->common.function_name;
              ^
    /root/xhprof/extension/xhprof.c:648:44: error: request for member ‘val’ in something not a structure or union
             cls = curr_func->common.scope->name->val;
                                                ^
    /root/xhprof/extension/xhprof.c:649:51: error: request for member ‘val’ in something not a structure or union
             spprintf(&ret, 0, "%s%s%s", cls, sep, func->val);
                                                       ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_inc_count’:
    /root/xhprof/extension/xhprof.c:737:10: warning: assignment makes pointer from integer without a cast [enabled by default]
         data = zend_hash_str_find(ht, name, strlen(name));
              ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_sample_stack’:
    /root/xhprof/extension/xhprof.c:790:57: error: macro "add_assoc_string" requires 4 arguments, but only 3 given
         add_assoc_string(&XHPROF_G(stats_count), key, symbol);
                                                             ^
    /root/xhprof/extension/xhprof.c:790:5: error: ‘add_assoc_string’ undeclared (first use in this function)
         add_assoc_string(&XHPROF_G(stats_count), key, symbol);
         ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_mode_hier_endfn_cb’:
    /root/xhprof/extension/xhprof.c:1027:12: warning: assignment makes pointer from integer without a cast [enabled by default]
         counts = zend_hash_str_find(Z_ARRVAL(XHPROF_G(stats_count)), symbol, strlen(symbol));
                ^
    /root/xhprof/extension/xhprof.c:1032:16: warning: assignment makes pointer from integer without a cast [enabled by default]
             counts = zend_hash_str_update(Z_ARRVAL(XHPROF_G(stats_count)), symbol, strlen(symbol), &count_val);
                    ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_execute_internal’:
    /root/xhprof/extension/xhprof.c:1125:9: warning: passing argument 2 of ‘execute_internal’ from incompatible pointer type [enabled by default]
             execute_internal(execute_data, return_value);
             ^
    In file included from /usr/local/php/include/php/Zend/zend_API.h:30:0,
                     from /usr/local/php/include/php/main/php.h:39,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_execute.h:62:15: note: expected ‘struct _zend_fcall_info *’ but argument is of type ‘struct zval *’
     ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC);
                   ^
    /root/xhprof/extension/xhprof.c:1125:9: error: too few arguments to function ‘execute_internal’
             execute_internal(execute_data, return_value);
             ^
    In file included from /usr/local/php/include/php/Zend/zend_API.h:30:0,
                     from /usr/local/php/include/php/main/php.h:39,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_execute.h:62:15: note: declared here
     ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC);
                   ^
    /root/xhprof/extension/xhprof.c:1140:9: warning: passing argument 2 of ‘execute_internal’ from incompatible pointer type [enabled by default]
             execute_internal(execute_data, return_value);
             ^
    In file included from /usr/local/php/include/php/Zend/zend_API.h:30:0,
                     from /usr/local/php/include/php/main/php.h:39,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_execute.h:62:15: note: expected ‘struct _zend_fcall_info *’ but argument is of type ‘struct zval *’
     ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC);
                   ^
    /root/xhprof/extension/xhprof.c:1140:9: error: too few arguments to function ‘execute_internal’
             execute_internal(execute_data, return_value);
             ^
    In file included from /usr/local/php/include/php/Zend/zend_API.h:30:0,
                     from /usr/local/php/include/php/main/php.h:39,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_execute.h:62:15: note: declared here
     ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC);
                   ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_zval_at_key’:
    /root/xhprof/extension/xhprof.c:1329:16: warning: assignment makes pointer from integer without a cast [enabled by default]
             result = zend_hash_str_find(Z_ARRVAL_P(values), key, len);
                    ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_strings_in_zval’:
    /root/xhprof/extension/xhprof.c:1354:9: error: unknown type name ‘zend_string’
             zend_string *key;
             ^
    /root/xhprof/extension/xhprof.c:1364:58: error: expected ‘;’ before ‘{’ token
             ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, key, val) {
                                                              ^
    /root/xhprof/extension/xhprof.c: At top level:
    /root/xhprof/extension/xhprof.c:1405:1: error: unknown type name ‘zend_string’
     zend_string *hp_pcre_match(char *pattern, int len, zval *data, zend_ulong idx)
     ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_pcre_match’:
    /root/xhprof/extension/xhprof.c:1410:5: error: unknown type name ‘zend_string’
         zend_string *pattern_str, *result = NULL;
         ^
    /root/xhprof/extension/xhprof.c:1412:17: warning: assignment makes pointer from integer without a cast [enabled by default]
         pattern_str = zend_string_init(pattern, len, 0);
                     ^
    /root/xhprof/extension/xhprof.c:1413:5: warning: passing argument 1 of ‘pcre_get_compiled_regex_cache’ from incompatible pointer type [enabled by default]
         if ((pce_regexp = pcre_get_compiled_regex_cache(pattern_str)) == NULL) {
         ^
    In file included from /root/xhprof/extension/xhprof.c:33:0:
    /usr/local/php/include/php/ext/pcre/php_pcre.h:55:26: note: expected ‘char *’ but argument is of type ‘int *’
     PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int regex_len TSRMLS_DC);
                              ^
    /root/xhprof/extension/xhprof.c:1413:5: error: too few arguments to function ‘pcre_get_compiled_regex_cache’
         if ((pce_regexp = pcre_get_compiled_regex_cache(pattern_str)) == NULL) {
         ^
    In file included from /root/xhprof/extension/xhprof.c:33:0:
    /usr/local/php/include/php/ext/pcre/php_pcre.h:55:26: note: declared here
     PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int regex_len TSRMLS_DC);
                              ^
    /root/xhprof/extension/xhprof.c:1425:9: error: too few arguments to function ‘zend_hash_index_find’
             match = zend_hash_index_find(Z_ARRVAL_P(subparts), idx);
             ^
    In file included from /usr/local/php/include/php/Zend/zend.h:286:0,
                     from /usr/local/php/include/php/main/php.h:35,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_hash.h:166:14: note: declared here
     ZEND_API int zend_hash_index_find(const HashTable *ht, ulong h, void **pData);
                  ^
    /root/xhprof/extension/xhprof.c:1428:20: warning: assignment makes pointer from integer without a cast [enabled by default]
                 result = zend_string_init(Z_STRVAL_P(match), Z_STRLEN_P(match), 0);
                        ^
    /root/xhprof/extension/xhprof.c:1433:5: warning: passing argument 1 of ‘_zval_ptr_dtor’ from incompatible pointer type [enabled by default]
         zval_ptr_dtor(&matches);
         ^
    In file included from /usr/local/php/include/php/Zend/zend.h:850:0,
                     from /usr/local/php/include/php/main/php.h:35,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_variables.h:51:15: note: expected ‘struct zval **’ but argument is of type ‘struct zval *’
     ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC);
                   ^
    /root/xhprof/extension/xhprof.c:1434:5: warning: passing argument 1 of ‘_zval_ptr_dtor’ from incompatible pointer type [enabled by default]
         zval_ptr_dtor(subparts);
         ^
    In file included from /usr/local/php/include/php/Zend/zend.h:850:0,
                     from /usr/local/php/include/php/main/php.h:35,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_variables.h:51:15: note: expected ‘struct zval **’ but argument is of type ‘struct zval *’
     ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC);
                   ^
    /root/xhprof/extension/xhprof.c: At top level:
    /root/xhprof/extension/xhprof.c:1439:1: error: unknown type name ‘zend_string’
     zend_string *hp_pcre_replace(char *pattern, int len, zval *repl, zval *data, int limit)
     ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_pcre_replace’:
    /root/xhprof/extension/xhprof.c:1442:5: error: unknown type name ‘zend_string’
         zend_string *pattern_str, *replace;
         ^
    /root/xhprof/extension/xhprof.c:1444:17: warning: assignment makes pointer from integer without a cast [enabled by default]
         pattern_str = zend_string_init(pattern, len, 0);
                     ^
    /root/xhprof/extension/xhprof.c:1446:5: warning: passing argument 1 of ‘pcre_get_compiled_regex_cache’ from incompatible pointer type [enabled by default]
         if ((pce_regexp = pcre_get_compiled_regex_cache(pattern_str)) == NULL) {
         ^
    In file included from /root/xhprof/extension/xhprof.c:33:0:
    /usr/local/php/include/php/ext/pcre/php_pcre.h:55:26: note: expected ‘char *’ but argument is of type ‘int *’
     PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int regex_len TSRMLS_DC);
                              ^
    /root/xhprof/extension/xhprof.c:1446:5: error: too few arguments to function ‘pcre_get_compiled_regex_cache’
         if ((pce_regexp = pcre_get_compiled_regex_cache(pattern_str)) == NULL) {
         ^
    In file included from /root/xhprof/extension/xhprof.c:33:0:
    /usr/local/php/include/php/ext/pcre/php_pcre.h:55:26: note: declared here
     PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(char *regex, int regex_len TSRMLS_DC);
                              ^
    /root/xhprof/extension/xhprof.c:1457:5: warning: passing argument 3 of ‘php_pcre_replace_impl’ makes integer from pointer without a cast [enabled by default]
         replace = php_pcre_replace_impl(pce_regexp, NULL, Z_STRVAL_P(repl), Z_STRLEN_P(repl), data, 0, limit, 0);
         ^
    In file included from /root/xhprof/extension/xhprof.c:33:0:
    /usr/local/php/include/php/ext/pcre/php_pcre.h:60:14: note: expected ‘int’ but argument is of type ‘char *’
     PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value,
                  ^
    /root/xhprof/extension/xhprof.c:1457:5: warning: passing argument 4 of ‘php_pcre_replace_impl’ makes pointer from integer without a cast [enabled by default]
         replace = php_pcre_replace_impl(pce_regexp, NULL, Z_STRVAL_P(repl), Z_STRLEN_P(repl), data, 0, limit, 0);
         ^
    In file included from /root/xhprof/extension/xhprof.c:33:0:
    /usr/local/php/include/php/ext/pcre/php_pcre.h:60:14: note: expected ‘struct zval *’ but argument is of type ‘int’
     PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value,
                  ^
    /root/xhprof/extension/xhprof.c:1457:5: warning: passing argument 5 of ‘php_pcre_replace_impl’ makes integer from pointer without a cast [enabled by default]
         replace = php_pcre_replace_impl(pce_regexp, NULL, Z_STRVAL_P(repl), Z_STRLEN_P(repl), data, 0, limit, 0);
         ^
    In file included from /root/xhprof/extension/xhprof.c:33:0:
    /usr/local/php/include/php/ext/pcre/php_pcre.h:60:14: note: expected ‘int’ but argument is of type ‘struct zval *’
     PHPAPI char *php_pcre_replace_impl(pcre_cache_entry *pce, char *subject, int subject_len, zval *return_value,
                  ^
    /root/xhprof/extension/xhprof.c:1457:13: warning: assignment from incompatible pointer type [enabled by default]
         replace = php_pcre_replace_impl(pce_regexp, NULL, Z_STRVAL_P(repl), Z_STRLEN_P(repl), data, 0, limit, 0);
                 ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_trace_callback_sql_query’:
    /root/xhprof/extension/xhprof.c:1474:21: warning: initialization makes pointer from integer without a cast [enabled by default]
             zval *arg = ZEND_CALL_ARG(data, 2);
                         ^
    /root/xhprof/extension/xhprof.c:1477:21: warning: initialization makes pointer from integer without a cast [enabled by default]
             zval *arg = ZEND_CALL_ARG(data, 1);
                         ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_trace_callback_pdo_statement_execute’:
    /root/xhprof/extension/xhprof.c:1488:25: error: ‘zend_execute_data’ has no member named ‘This’
         zval *object = (data->This.value.obj) ? &(data->This) : NULL;
                             ^
    /root/xhprof/extension/xhprof.c:1488:51: error: ‘zend_execute_data’ has no member named ‘This’
         zval *object = (data->This.value.obj) ? &(data->This) : NULL;
                                                       ^
    /root/xhprof/extension/xhprof.c:1492:9: error: too many arguments to function ‘zend_read_property’
             query_string = zend_read_property(pdo_ce, object, ZEND_STRL("queryString"), 0, NULL);
             ^
    In file included from /usr/local/php/include/php/main/php.h:39:0,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_API.h:343:16: note: declared here
     ZEND_API zval *zend_read_property(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_bool silent TSRMLS_DC);
                    ^
    /root/xhprof/extension/xhprof.c:1509:13: warning: assignment makes pointer from integer without a cast [enabled by default]
             arg = ZEND_CALL_ARG(data, 1);
                 ^
    /root/xhprof/extension/xhprof.c:1515:9: error: unknown type name ‘zend_string’
             zend_string *pattern_str = NULL;
             ^
    /root/xhprof/extension/xhprof.c:1520:25: warning: assignment makes pointer from integer without a cast [enabled by default]
                 pattern_str = zend_string_init("([\?])", sizeof("([\?])") - 1, 0);
                             ^
    /root/xhprof/extension/xhprof.c:1522:25: warning: assignment makes pointer from integer without a cast [enabled by default]
                 pattern_str = zend_string_init("(:([^\\s]+))", sizeof("(:([^\\s]+))") - 1, 0);
                             ^
    /root/xhprof/extension/xhprof.c:1526:13: error: unknown type name ‘zend_string’
                 zend_string *match;
                 ^
    /root/xhprof/extension/xhprof.c:1527:13: warning: passing argument 1 of ‘hp_pcre_match’ makes pointer from integer without a cast [enabled by default]
                 if ((match = hp_pcre_match(ZSTR_VAL(pattern_str), ZSTR_LEN(pattern_str), &copy_query, 0))) {
                 ^
    /root/xhprof/extension/xhprof.c:1405:14: note: expected ‘char *’ but argument is of type ‘int’
     zend_string *hp_pcre_match(char *pattern, int len, zval *data, zend_ulong idx)
                  ^
    /root/xhprof/extension/xhprof.c:1529:17: error: unknown type name ‘zend_string’
                     zend_string *key;
                     ^
    /root/xhprof/extension/xhprof.c:1531:17: error: unknown type name ‘zend_string’
                     zend_string *replace;
                     ^
    /root/xhprof/extension/xhprof.c:1534:17: error: expected ‘;’ before ‘{’ token
                     {
                     ^
    /root/xhprof/extension/xhprof.c:1555:9: warning: passing argument 1 of ‘_zval_ptr_dtor’ from incompatible pointer type [enabled by default]
             zval_ptr_dtor(&copy_query);
             ^
    In file included from /usr/local/php/include/php/Zend/zend.h:850:0,
                     from /usr/local/php/include/php/main/php.h:35,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_variables.h:51:15: note: expected ‘struct zval **’ but argument is of type ‘struct zval *’
     ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC);
                   ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_trace_callback_curl_exec’:
    /root/xhprof/extension/xhprof.c:1568:17: warning: initialization makes pointer from integer without a cast [enabled by default]
         zval *arg = ZEND_CALL_ARG(data, 1);
                     ^
    /root/xhprof/extension/xhprof.c:1576:38: error: macro "ZVAL_STRING" requires 3 arguments, but only 2 given
         ZVAL_STRING(&func, "curl_getinfo");
                                          ^
    /root/xhprof/extension/xhprof.c:1576:5: error: ‘ZVAL_STRING’ undeclared (first use in this function)
         ZVAL_STRING(&func, "curl_getinfo");
         ^
    /root/xhprof/extension/xhprof.c:1583:13: error: incompatible types when initializing type ‘struct zval *’ using type ‘zval’
                 function_name: func,
                 ^
    /root/xhprof/extension/xhprof.c:1587:13: error: unknown field ‘retval’ specified in initializer
                 retval: &retval,
                 ^
    /root/xhprof/extension/xhprof.c:1587:13: warning: initialization from incompatible pointer type [enabled by default]
    /root/xhprof/extension/xhprof.c:1587:13: warning: (near initialization for ‘fci.retval_ptr_ptr’) [enabled by default]
    /root/xhprof/extension/xhprof.c:1588:13: warning: initialization from incompatible pointer type [enabled by default]
                 params: &params,
                 ^
    /root/xhprof/extension/xhprof.c:1588:13: warning: (near initialization for ‘fci.params’) [enabled by default]
    /root/xhprof/extension/xhprof.c:1589:13: error: unknown field ‘object’ specified in initializer
                 object: NULL,
                 ^
    /root/xhprof/extension/xhprof.c:1597:16: warning: assignment makes pointer from integer without a cast [enabled by default]
             option = zend_hash_str_find(Z_ARRVAL(retval), ZEND_STRL("url"));
                    ^
    /root/xhprof/extension/xhprof.c:1601:5: warning: passing argument 1 of ‘_zval_ptr_dtor’ from incompatible pointer type [enabled by default]
         zval_ptr_dtor(&func);
         ^
    In file included from /usr/local/php/include/php/Zend/zend.h:850:0,
                     from /usr/local/php/include/php/main/php.h:35,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_variables.h:51:15: note: expected ‘struct zval **’ but argument is of type ‘struct zval *’
     ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC);
                   ^
    /root/xhprof/extension/xhprof.c:1602:5: warning: passing argument 1 of ‘_zval_ptr_dtor’ from incompatible pointer type [enabled by default]
         zval_ptr_dtor(&retval);
         ^
    In file included from /usr/local/php/include/php/Zend/zend.h:850:0,
                     from /usr/local/php/include/php/main/php.h:35,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_variables.h:51:15: note: expected ‘struct zval **’ but argument is of type ‘struct zval *’
     ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC);
                   ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_get_trace_callback’:
    /root/xhprof/extension/xhprof.c:1612:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
         callback = (hp_trace_callback*)zend_hash_str_find_ptr(XHPROF_G(trace_callbacks), symbol, strlen(symbol));
                    ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_free_trace_callbacks’:
    /root/xhprof/extension/xhprof.c:1625:5: warning: passing argument 1 of ‘_efree’ makes pointer from integer without a cast [enabled by default]
         efree(Z_PTR_P(val));
         ^
    In file included from /usr/local/php/include/php/Zend/zend.h:252:0,
                     from /usr/local/php/include/php/main/php.h:35,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_alloc.h:61:15: note: expected ‘void *’ but argument is of type ‘int’
     ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
                   ^
    /root/xhprof/extension/xhprof.c: In function ‘hp_init_trace_callbacks’:
    /root/xhprof/extension/xhprof.c:1643:5: warning: passing argument 3 of ‘_zend_hash_init’ from incompatible pointer type [enabled by default]
         zend_hash_init(XHPROF_G(trace_callbacks), 8, NULL, hp_free_trace_callbacks, 0);
         ^
    In file included from /usr/local/php/include/php/Zend/zend.h:286:0,
                     from /usr/local/php/include/php/main/php.h:35,
                     from /root/xhprof/extension/xhprof.c:22:
    /usr/local/php/include/php/Zend/zend_hash.h:100:14: note: expected ‘dtor_func_t’ but argument is of type ‘void (*)(struct zval *)’
     ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC);
    
    
    opened by zarte 6
  • Does major performance impact?

    Does major performance impact?

    <?php
    
    $enableProfiling = $_ENV['ENABLE_PROFILING'] ?? false;
    
    if ($enableProfiling) {
        xhprof_enable();
    }
    
    $start = microtime(true);
    
    $test = 'abcd';
    
    for ($i = 0; $i < 1_000_000; $i++) {
        $test = md5($test);
    }
    
    echo sprintf('Elapsed: %f', microtime(true) - $start) . PHP_EOL;
    
    if ($enableProfiling) {
        xhprof_disable();
    }
    

    ENABLE_PROFILING=1 php ./bin/test.php Elapsed: 9.300184

    ENABLE_PROFILING=0 php ./bin/test.php Elapsed: 0.386227

    I did something wrong or it's normal behaviour?

    PHP 8.0/7.3, xhprof 2.3.5.

    opened by iNiSiRe 1
  • open for maintenance ?

    open for maintenance ?

    Hi ! I would like to make some changes to make XHprof UI usable with recent PHP versions

    Would you agree for some PRs ? (only agree if you will review and try to merge my work ;) )

    opened by williamdes 1
Releases(v2.3.9)
PHP 祖传代码跑路拯救者,支持 PHP5 & PHP7

PHP 祖传代码跑路拯救者,支持 PHP5 & PHP7 以下是我的线上实测版本 5.3.29 CLI 5.3.29 PHP-FPM 5.4.32 CLI 5.4.32 PHP-FPM 5.6.40 CLI 5.6.40 PHP-FPM 7.2.5 CLI 7.2.5 PHP-FPM 安装 如果安装

周梦康 77 Aug 30, 2022
EMR and PM Software written in PHP7

ReadMe IMWEMR is EMR/PM software, along with integrated iascemr (surgerycenter) and optical, repo is ready and preconfigured for subdomain http://demo

null 1 Dec 4, 2021
Magento2 + Varnish + PHP7 + Redis + SSL (cluster ready)

Docker Magento2: Varnish + PHP7 + Redis + SSL cluster ready docker-compose infrastructure Infrastructure overview Container 1: MariaDB Container 2: Re

Fabrizio Balliano 332 Dec 30, 2022
A QR Code generator for PHP7.4+

chillerlan/php-qrcode A PHP 7.4+ QR Code library based on the implementation by Kazuhiko Arase, namespaced, cleaned up, improved and other stuff. Docu

chillerlan 1.2k Dec 30, 2022
Modello base con tutto il docker configurato per php7.4, mariadb, vue3, apache...con esempi di component e chiamate rest interne

Applicazione base per utilizzare laravel con docker, php7.4, apache, mariadb10, vue3 Semplice installazione corredate di rotte web e api di base, 3 co

null 0 Jul 14, 2022
Easy XHProf setup to profile your laravel application!

Introduction Laravel XHProf provides you with a simple setup to profile your laravel application with the well known XHProf php extension originally d

Zacharias Creutznacher 122 Dec 23, 2022
PHP 祖传代码跑路拯救者,支持 PHP5 & PHP7

PHP 祖传代码跑路拯救者,支持 PHP5 & PHP7 以下是我的线上实测版本 5.3.29 CLI 5.3.29 PHP-FPM 5.4.32 CLI 5.4.32 PHP-FPM 5.6.40 CLI 5.6.40 PHP-FPM 7.2.5 CLI 7.2.5 PHP-FPM 安装 如果安装

周梦康 77 Aug 30, 2022
EMR and PM Software written in PHP7

ReadMe IMWEMR is EMR/PM software, along with integrated iascemr (surgerycenter) and optical, repo is ready and preconfigured for subdomain http://demo

null 1 Dec 4, 2021
Vagrant configuration for PHP7, Phalcon 3.x and Zephir development.

Phalcon VM 2.0.1 Phalcon VM is an open source Vagrant configuration which contains wide range of tools required in modern web development. Like a Swis

Eugene Manuilov 42 Nov 17, 2022
Phalcon 3, PHP7, Docker sample starter application

Phalcon Docker Nginx starter app Docker image based on: Ubuntu 16.04 Phalcon 3 PHP 7 Nginx + PHP FPM Supervisord Dependencies Docker. For installation

Guilherme Viebig 25 Oct 7, 2022
🧾 Online test site with the human sciences theme. Using: HTML5, CSS3, Js., PHP7 and MySQL. 🚀

form-ciencias-humanas ?? Technologies Lunacy HTML5 CSS3 PHP7 MYSQL Animate.css Illustrations from icons8: Earth care from Anna Antipina Earth and Moon

Vinícius 1 Jan 9, 2022
Magento2 + Varnish + PHP7 + Redis + SSL (cluster ready)

Docker Magento2: Varnish + PHP7 + Redis + SSL cluster ready docker-compose infrastructure Infrastructure overview Container 1: MariaDB Container 2: Re

Fabrizio Balliano 332 Dec 30, 2022
The fastest pure PHP database framework with a powerful static code generator, supports horizontal scale up, designed for PHP7

Maghead 4.0.x IS CURRENTLY UNDER HEAVY DEVELOPMENT, API IS NOT STABLE Maghead is an open-source Object-Relational Mapping (ORM) designed for PHP7. Mag

Maghead 477 Dec 24, 2022
A QR Code generator for PHP7.4+

chillerlan/php-qrcode A PHP 7.4+ QR Code library based on the implementation by Kazuhiko Arase, namespaced, cleaned up, improved and other stuff. Docu

chillerlan 1.2k Dec 30, 2022
Modello base con tutto il docker configurato per php7.4, mariadb, vue3, apache...con esempi di component e chiamate rest interne

Applicazione base per utilizzare laravel con docker, php7.4, apache, mariadb10, vue3 Semplice installazione corredate di rotte web e api di base, 3 co

null 0 Jul 14, 2022