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

Segmentation Fault Occur when Apache-Worker restart #338

Open
illef opened this issue Jul 12, 2017 · 4 comments
Open

Segmentation Fault Occur when Apache-Worker restart #338

illef opened this issue Jul 12, 2017 · 4 comments

Comments

@illef
Copy link

illef commented Jul 12, 2017

Segmentation Fault Occur in Apache-Worker restart

Repro Steps

  • build Examples/FunctionNoParameters using GCC 5.2.1, and add it to php.ini
  • apache-worker start : OK
  • apache-worker restart : Segmentation Fault

apache error log

  • seg fault or similar nasty error detected in the parent process

gdb

Program received signal SIGSEGV, Segmentation fault.
0x00007f778666535b in sapi_register_post_entry (post_entry=post_entry@entry=0x7f7786fd4b40 <php_post_entries>)
at /share/sources/php/php-7.0.14/main/SAPI.c:952
952 if (SG(sapi_started) && EG(current_execute_data)) {

backtrace

#0 0x00007f778666535b in sapi_register_post_entry (post_entry=post_entry@entry=0x7f7786fd4b40 <php_post_entries>)
at /share/sources/php/php-7.0.14/main/SAPI.c:952
#1 0x00007f7786665452 in sapi_register_post_entries (post_entries=post_entries@entry=0x7f7786fd4b40 <php_post_entries>)
at /share/sources/php/php-7.0.14/main/SAPI.c:941
#2 0x00007f7786668680 in php_setup_sapi_content_types () at /share/sources/php/php-7.0.14/main/php_content_types.c:64
#3 0x00007f7786656f6c in ts_allocate_id (rsrc_id=rsrc_id@entry=0x7f7786ff76c8 <sapi_globals_id>, size=size@entry=560,
ctor=ctor@entry=0x7f7786662ea0 <sapi_globals_ctor>, dtor=dtor@entry=0x7f7786662e80 <sapi_globals_dtor>)
at /share/sources/php/php-7.0.14/TSRM/TSRM.c:259
#4 0x00007f778666325c in sapi_startup (sf=sf@entry=0x7f7786fde4a0 <apache2_sapi_module>)
at /share/sources/php/php-7.0.14/main/SAPI.c:84
#5 0x00007f778676d3cc in php_apache_server_startup (pconf=0x18dd138, plog=, ptemp=,
s=) at /share/sources/php/php-7.0.14/sapi/apache2handler/sapi_apache2.c:463
#6 0x000000000044ccb3 in ap_run_post_config (pconf=pconf@entry=0x18dd138, plog=0x190a378, ptemp=0x1908348, s=0x190ec88)
at config.c:103
#7 0x000000000042ba05 in main (argc=3, argv=0x7ffd9875e6d8) at main.c:765

@stamster
Copy link

sapi_apache2.
Have you tried with different SAPI, i.e. PHP-FPM or even CGI?

@illef
Copy link
Author

illef commented Aug 8, 2017

It is OK with PHP-FPM , CGI and apache2-prefork.
Crash is reported in apache2-worker(ZTS).

@stamster
Copy link

stamster commented Aug 9, 2017

Apache2 SAPI is known to cause those kinds of issues with other low level projects as well.

I'm only using PHP-FPM SAPI, thus, have no issues of a kind.

@sjinks
Copy link
Contributor

sjinks commented Dec 26, 2017

Seems to be a PHP bug:

#include <sapi/embed/php_embed.h>

int main(int argc, char** argv)
{
        PHP_EMBED_START_BLOCK(0, 0)
        PHP_EMBED_END_BLOCK();

        PHP_EMBED_START_BLOCK(0, 0)
        PHP_EMBED_END_BLOCK();

        return 0;
}
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff73d826b in sapi_register_post_entry (post_entry=post_entry@entry=0x7ffff7dae160 <php_post_entries>) at /tmp/php-build/source/7.1.12/main/SAPI.c:951
951             if (SG(sapi_started) && EG(current_execute_data)) {
(gdb) bt
#0  0x00007ffff73d826b in sapi_register_post_entry (post_entry=post_entry@entry=0x7ffff7dae160 <php_post_entries>) at /tmp/php-build/source/7.1.12/main/SAPI.c:951
#1  0x00007ffff73d8362 in sapi_register_post_entries (post_entries=post_entries@entry=0x7ffff7dae160 <php_post_entries>) at /tmp/php-build/source/7.1.12/main/SAPI.c:940
#2  0x00007ffff73db5d0 in php_setup_sapi_content_types () at /tmp/php-build/source/7.1.12/main/php_content_types.c:64
#3  0x00007ffff73ca23c in ts_allocate_id (rsrc_id=rsrc_id@entry=0x7ffff7dd67b8 <sapi_globals_id>, size=size@entry=560, ctor=ctor@entry=0x7ffff73d5db0 <sapi_globals_ctor>, dtor=dtor@entry=0x7ffff73d5d90 <sapi_globals_dtor>) at /tmp/php-build/source/7.1.12/TSRM/TSRM.c:259
#4  0x00007ffff73d616c in sapi_startup (sf=sf@entry=0x7ffff7db7e40 <php_embed_module>) at /tmp/php-build/source/7.1.12/main/SAPI.c:84
#5  0x00007ffff74f2f74 in php_embed_init (argc=0, argv=0x0) at /tmp/php-build/source/7.1.12/sapi/embed/php_embed.c:182
#6  0x0000555555554a2e in main () at test.c:8

I suspect that this sequence:

    php_request_shutdown((void *) 0);
    php_module_shutdown();
    sapi_shutdown();
    tsrm_shutdown();

does not clear everything properly and PHP dies on sapi_startup().

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

No branches or pull requests

3 participants