zendtech / ZendOptimizerPlus

Other
914 stars 142 forks source link

Opcache crashing PHP #177

Open snajpa opened 10 years ago

snajpa commented 10 years ago

Hi,

opcache seems to be segfaulting the PHP-FPM process, but it doesn't seem to be reproducible by a concrete page reload, but it does happen constantly at least several times a day.

Our setup is PHP-FPM 5.3.28 + Opcache 7.0.3 running on Scientific Linux 6.4.

I have at least three valid core dumps capturing the segfault, how can I deliver them to you or do you want just specific info from there?

snajpa commented 10 years ago
(gdb) backtrace
#0  __memset_sse2 () at ../sysdeps/x86_64/memset.S:881
#1  0x00007f6db38b385c in zend_shared_alloc (size=20984)
    at /usr/include/bits/string3.h:85
#2  0x00007f6db38ae0f4 in cache_script_in_shared_memory (file_handle=0x7fff7a1ad4c0, 
    type=8, 
    key=0x7f6db3ac2e0c "/var/www/virtual/app42/htdocs:includes/functions/validations.php:/var/www/virtual/app42/htdocs/includes:A", key_length=105, op_array_p=0x7fff7a1ad460, 
    from_shared_memory=0x7fff7a1ad468)
    at /root/rpmbuild/BUILD/zendopcache-7.0.3/ZendAccelerator.c:1172
#3  compile_and_cache_file (file_handle=0x7fff7a1ad4c0, type=8, 
    key=0x7f6db3ac2e0c "/var/www/virtual/app42/htdocs:includes/functions/validations.php:/var/www/virtual/app42/htdocs/includes:A", key_length=105, op_array_p=0x7fff7a1ad460, 
    from_shared_memory=0x7fff7a1ad468)
    at /root/rpmbuild/BUILD/zendopcache-7.0.3/ZendAccelerator.c:1464
#4  0x00007f6db38aedd3 in persistent_compile_file (file_handle=0x7fff7a1ad4c0, type=8)
    at /root/rpmbuild/BUILD/zendopcache-7.0.3/ZendAccelerator.c:1641
#5  0x00000000008212fe in compile_filename (type=8, filename=0x7f6db02f0490)
    at Zend/zend_language_scanner.l:407
#6  0x0000000000876fe3 in ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER (
    execute_data=0x7f6db02f01b0) at /usr/src/debug/php-5.3.28/Zend/zend_vm_execute.h:5257
#7  0x000000000086bdf0 in execute (op_array=0x377d6e8)
    at /usr/src/debug/php-5.3.28/Zend/zend_vm_execute.h:107
#8  0x00000000008456ff in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /usr/src/debug/php-5.3.28/Zend/zend.c:1259
#9  0x00000000007f2268 in php_execute_script (primary_file=0x7fff7a1afe30)
    at /usr/src/debug/php-5.3.28/main/main.c:2316
#10 0x00000000008d8108 in main (argc=<value optimized out>, argv=<value optimized out>)
    at /usr/src/debug/php-5.3.28/sapi/fpm/fpm/fpm_main.c:1929
#0  __memset_sse2 () at ../sysdeps/x86_64/memset.S:881
#1  0x00007f3f5cbbd85c in zend_shared_alloc (size=397008)
    at /usr/include/bits/string3.h:85
#2  0x00007f3f5cbb80f4 in cache_script_in_shared_memory (file_handle=0x7fffc0f27e90, 
    type=8, 
    key=0x7f3f5cdcce0c "/var/www/virtual/app42/htdocs:includes/functions/general.php:/var/www/virtual/app42/htdocs/includes:A", key_length=101, op_array_p=0x7fffc0f27e30, 
    from_shared_memory=0x7fffc0f27e38)
    at /root/rpmbuild/BUILD/zendopcache-7.0.3/ZendAccelerator.c:1172
#3  compile_and_cache_file (file_handle=0x7fffc0f27e90, type=8, 
    key=0x7f3f5cdcce0c "/var/www/virtual/app42/htdocs:includes/functions/general.php:/var/www/virtual/app42/htdocs/includes:A", key_length=101, op_array_p=0x7fffc0f27e30, 
    from_shared_memory=0x7fffc0f27e38)
    at /root/rpmbuild/BUILD/zendopcache-7.0.3/ZendAccelerator.c:1464
#4  0x00007f3f5cbb8dd3 in persistent_compile_file (file_handle=0x7fffc0f27e90, type=8)
    at /root/rpmbuild/BUILD/zendopcache-7.0.3/ZendAccelerator.c:1641
#5  0x00000000008212fe in compile_filename (type=8, filename=0x7f3f595fa448)
    at Zend/zend_language_scanner.l:407
#6  0x0000000000876fe3 in ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER (
    execute_data=0x7f3f595fa168) at /usr/src/debug/php-5.3.28/Zend/zend_vm_execute.h:5257
#7  0x000000000086bdf0 in execute (op_array=0x38b5430)
    at /usr/src/debug/php-5.3.28/Zend/zend_vm_execute.h:107
#8  0x00000000008456ff in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /usr/src/debug/php-5.3.28/Zend/zend.c:1259
#9  0x00000000007f2268 in php_execute_script (primary_file=0x7fffc0f2a800)
    at /usr/src/debug/php-5.3.28/main/main.c:2316
#10 0x00000000008d8108 in main (argc=<value optimized out>, argv=<value optimized out>)
    at /usr/src/debug/php-5.3.28/sapi/fpm/fpm/fpm_main.c:1929
#0  __memset_sse2 () at ../sysdeps/x86_64/memset.S:878
#1  0x00007fe31174f85c in zend_shared_alloc (size=731240)
    at /usr/include/bits/string3.h:85
#2  0x00007fe31174a0f4 in cache_script_in_shared_memory (file_handle=0x7fffe70897e0, 
    type=2, 
    key=0x7fe31195ee0c "/var/www/virtual/app42/htdocs/includes/classes/seo.class.php", 
    key_length=60, op_array_p=0x7fffe7089770, from_shared_memory=0x7fffe7089778)
    at /root/rpmbuild/BUILD/zendopcache-7.0.3/ZendAccelerator.c:1172
#3  compile_and_cache_file (file_handle=0x7fffe70897e0, type=2, 
    key=0x7fe31195ee0c "/var/www/virtual/app42/htdocs/includes/classes/seo.class.php", 
    key_length=60, op_array_p=0x7fffe7089770, from_shared_memory=0x7fffe7089778)
    at /root/rpmbuild/BUILD/zendopcache-7.0.3/ZendAccelerator.c:1464
#4  0x00007fe31174add3 in persistent_compile_file (file_handle=0x7fffe70897e0, type=2)
    at /root/rpmbuild/BUILD/zendopcache-7.0.3/ZendAccelerator.c:1641
#5  0x0000000000877204 in ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER (
    execute_data=0x7fe31018c1b0) at /usr/src/debug/php-5.3.28/Zend/zend_vm_execute.h:5237
#6  0x000000000086bdf0 in execute (op_array=0x1cdf390)
    at /usr/src/debug/php-5.3.28/Zend/zend_vm_execute.h:107
#7  0x00000000008456ff in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /usr/src/debug/php-5.3.28/Zend/zend.c:1259
#8  0x00000000007f2268 in php_execute_script (primary_file=0x7fffe708c060)
    at /usr/src/debug/php-5.3.28/main/main.c:2316
#9  0x00000000008d8108 in main (argc=<value optimized out>, argv=<value optimized out>)
    at /usr/src/debug/php-5.3.28/sapi/fpm/fpm/fpm_main.c:1929
laruence commented 10 years ago

what is your opcache ini configs? (in php.ini)

snajpa commented 10 years ago

Note that enable=0 is now set temporarily to avoid the segfaults, otherwise it's original.

 / # cat /etc/php.d/zendopcache.ini | grep -vP "^;.*"
zend_extension=/usr/lib64/20090626/zendopcache.so
opcache.enable = 0

opcache.enable_cli = 0

opcache.memory_consumption = 2048

opcache.interned_strings_buffer = 256

opcache.max_accelerated_files = 60000

opcache.max_wasted_percentage = 5

opcache.use_cwd = 1

opcache.validate_timestamps = 1

opcache.revalidate_freq = 120

opcache.file_update_protection = 2

opcache.revalidate_path = 0

opcache.save_comments = 1

opcache.load_comments = 1

opcache.fast_shutdown = 0

opcache.enable_file_override = 1

opcache.optimization_level = 0xffffffff

opcache.inherited_hack = 1

opcache.blacklist_filename = ""

opcache.max_file_size = 0

opcache.consistency_checks = 0

opcache.force_restart_timeout = 910

opcache.error_log = ""

opcache.log_verbosity_level = 3

opcache.preferred_memory_model = ""

opcache.protect_memory = 0
laruence commented 10 years ago
opcache.enable = 0

opcache.enable_cli = 0

is that real? you get segfault when you running some cli app?

is it possible to get a refined reproduce script?

snajpa commented 10 years ago

See the note above the output, I've disabled opcache to avoid the segfaults.

But enable_cli is disabled from the start, it doesn't make much sense to cache the cron CLI runs.