Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug segfault due to EX(opline) might be NULL #32

Closed
wants to merge 7 commits into from
Closed

Fixed bug segfault due to EX(opline) might be NULL #32

wants to merge 7 commits into from

Conversation

laruence
Copy link

this bug only exists in PHP-5.5

reproduce script:

<?php

xhprof_enable(XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);
function load($name) {
}
spl_autoload_register("load");

new A();

will segfault with backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x00002aaaaef62494 in hp_execute_internal (execute_data=0x7fffffffa8c0, fci=0x7fffffffaa70, ret=1)
    at /home/huixinchen/opensource/github/xhprof/extension/xhprof.c:1708
1708        temp_variable *retvar = &EX_T(opline->result.var);
(gdb) bt
#0  0x00002aaaaef62494 in hp_execute_internal (execute_data=0x7fffffffa8c0, fci=0x7fffffffaa70, ret=1)
    at /home/huixinchen/opensource/github/xhprof/extension/xhprof.c:1708
#1  0x00000000008d9d71 in zend_call_function (fci=0x7fffffffaa70, fci_cache=0x7fffffffaa40)
    at /home/huixinchen/opensource/php-5.5/Zend/zend_execute_API.c:959
#2  0x00000000008da805 in zend_lookup_class_ex (name=0x2aaaaf26f718 "A", name_length=1, key=0x2aaaaf69b800,
    use_autoload=1, ce=0x7fffffffabb0) at /home/huixinchen/opensource/php-5.5/Zend/zend_execute_API.c:1115
#3  0x00000000008db90a in zend_fetch_class_by_name (class_name=0x2aaaaf26f718 "A", class_name_len=1,
    key=0x2aaaaf69b800, fetch_type=4) at /home/huixinchen/opensource/php-5.5/Zend/zend_execute_API.c:1595
#4  0x000000000092d15c in ZEND_FETCH_CLASS_SPEC_CONST_HANDLER (execute_data=0x2aaaab156128)
    at /home/huixinchen/opensource/php-5.5/Zend/zend_vm_execute.h:1197
#5  0x000000000092a12b in execute_ex (execute_data=0x2aaaab156128)
    at /home/huixinchen/opensource/php-5.5/Zend/zend_vm_execute.h:363
#6  0x000000000092a1b4 in zend_execute (op_array=0x2aaaab191650)
    at /home/huixinchen/opensource/php-5.5/Zend/zend_vm_execute.h:388

oliworx and others added 7 commits April 10, 2013 12:14
call graph: changed color of arrows/edges to grey for better 
readability of the labels
fixes PR #20 when using randomly generated run ids
Ignore build artifacts from Git
call graph: changed color of arrows/edges to grey for readability
glennpratt added a commit to acquia/xhprof that referenced this pull request Jan 24, 2014
…p.net/bug.php?id=65345.

Stop using this when the issue is fixed in a PECL release.
@robocoder
Copy link
Contributor

That seems to fix the xhprof_enable(), but I'm seeing a segfault on xhprof_disable().

#0  0x00007ffff3f44358 in ?? () from /usr/lib/apache2/modules/libphp5.so
#1  0x00007ffff3f45195 in gc_collect_cycles () from /usr/lib/apache2/modules/libphp5.so
#2  0x00007ffff3f45524 in gc_zval_possible_root () from /usr/lib/apache2/modules/libphp5.so
#3  0x00007ffff3f33e88 in zend_hash_destroy () from /usr/lib/apache2/modules/libphp5.so
#4  0x00007ffff3f24b1b in _zval_dtor_func () from /usr/lib/apache2/modules/libphp5.so
#5  0x00007fffe2f71c5d in _zval_dtor (zvalue=<optimized out>) at /usr/include/php5/Zend/zend_variables.h:35
#6  hp_clean_profiler_state () at /tmp/xhprof-0.9.4/extension/xhprof.c:696
#7  0x00007fffe2f73371 in hp_end () at /tmp/xhprof-0.9.4/extension/xhprof.c:1894
#8  zm_deactivate_xhprof (type=<optimized out>, module_number=<optimized out>) at /tmp/xhprof-0.9.4/extension/xhprof.c:512
#9  zm_deactivate_xhprof (type=<optimized out>, module_number=<optimized out>) at /tmp/xhprof-0.9.4/extension/xhprof.c:511
#10 0x00007ffff3f2d284 in zend_deactivate_modules () from /usr/lib/apache2/modules/libphp5.so
#11 0x00007ffff3ec4255 in php_request_shutdown () from /usr/lib/apache2/modules/libphp5.so
#12 0x00007ffff3fd3347 in ?? () from /usr/lib/apache2/modules/libphp5.so
#13 0x00005555555aa548 in ap_run_handler ()
#14 0x00005555555aab3e in ap_invoke_handler ()
#15 0x00005555555bfdcc in ap_internal_redirect ()
#16 0x00007ffff20b5355 in ?? () from /usr/lib/apache2/modules/mod_rewrite.so
#17 0x00005555555aa548 in ap_run_handler ()
#18 0x00005555555aab3e in ap_invoke_handler ()
#19 0x00005555555c0b5a in ap_process_async_request ()
#20 0x00005555555c0cbf in ap_process_request ()
#21 0x00005555555bd1c5 in ?? ()
#22 0x00005555555b3ba8 in ap_run_process_connection ()
#23 0x00007ffff489c633 in ?? () from /usr/lib/apache2/modules/mod_mpm_prefork.so
#24 0x00007ffff489c852 in ?? () from /usr/lib/apache2/modules/mod_mpm_prefork.so
#25 0x00007ffff489d89e in ?? () from /usr/lib/apache2/modules/mod_mpm_prefork.so
#26 0x000055555558fe26 in ap_run_mpm ()
#27 0x0000555555589418 in main ()

Maybe we shouldn't be calling xhprof_disable() from an auto_append_file script?

@billf
Copy link
Contributor

billf commented Apr 11, 2014

@laruence can you sign the contributor agreement at https://code.facebook.com/cla

@laruence
Copy link
Author

@billf, sure, signed. thanks

@billf
Copy link
Contributor

billf commented Apr 11, 2014

this fails the test suite for me

XHPRrof: Test Include File (load/run_init operations)
Author: Kannan [tests/xhprof_004.phpt]
XHPRrof: Test excluding call_user_func and similar functions
Author: mpal [tests/xhprof_007.phpt]

Darwin - Darwin bill-retina.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
PHP API => 20121113
PHP Extension => 20121212
Zend Extension => 220121212
Zend Extension Build => API220121212,NTS
PHP Extension Build => API20121212,NTS
PHP Version => 5.5.11

@robocoder
Copy link
Contributor

@billf I recommend closing this PR in favour of #33

@epriestley
Copy link
Member

This project has a new maintainer, Phacility. We worked with the original developers and maintainers of XHProf at Facebook until 2011/2012. We recently offered to take over maintenance because we use XHProf heavily in our software (Phabricator) while Facebook is now focused on the HHVM platform and relies on XHProf much less than it once did.

I'm trying to clear out the backlog of open requests and issues.

Tentatively, I agree with @robocoder that #33 is the better fix here. I'm going to close it in favor of that.

@epriestley epriestley closed this Aug 27, 2014
@LionsAd LionsAd mentioned this pull request Nov 6, 2015
@Minasu Minasu mentioned this pull request Jun 20, 2016
yazshel pushed a commit to FluentDevelopment/xhprof that referenced this pull request Dec 3, 2020
phacility#32 fix for PHP 7.4
yazshel pushed a commit to FluentDevelopment/xhprof that referenced this pull request Dec 3, 2020
phacility#32 modify 7.4 removed typedefs
yazshel pushed a commit to FluentDevelopment/xhprof that referenced this pull request Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants