php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68104 Opcache crashes randomly and on Scripts with many includes
Submitted: 2014-09-26 07:16 UTC Modified: -
Votes:9
Avg. Score:4.8 ± 0.6
Reproduced:9 of 9 (100.0%)
Same Version:9 (100.0%)
Same OS:4 (44.4%)
From: andre4tw at gmail dot com Assigned:
Status: Closed Package: opcache
PHP Version: 5.6.0 OS: Debian 7.0 Wheezy
Private report: No CVE-ID: None
 [2014-09-26 07:16 UTC] andre4tw at gmail dot com
Description:
------------
## Description
When opcache is enabled scripts randomly crashing. The PHP-FPM log showing lots of exited with signal 15 errors. When I disable opcache with ini_set('opcache.enable', 0) I have no errors so far.
This error do not appear in PHP 5.5.17.
I noticed instant crashes, if you have scripts with large includes. (Google YouTube API class for example). Loading the page forces an instant crash of the PHP-FPM Pool. FPM-Pools from smaller scripts crashing time by time with signal 15.

## Informations
System: Nginx with PHP-FPM (UNIX-Socket communication)
Using included opcache module
Compiled with: ./configure --prefix=/usr/local --with-bz2 --enable-calendar --with-curl --enable-exif --enable-ftp --with-gd --with-jpeg-dir --enable-gd-native-ttf --enable-mbstring --with-mcrypt --with-openssl --with-pcre-regex --enable-soap --enable-sockets --enable-zip --with-zlib --enable-fpm --with-config-file-path=/etc/php5 --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-pdo-mysql --with-mysqli --enable-shmop --enable-opcache

## php.ini opcache config
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/opcache.so
opcache.enable_cli = 1
opcache.fast_shutdown = 1
opcache.memory_consumption = 196
opcache.max_accelerated_files = 7000
opcache.interned_strings_buffer = 16
opcache.revalidate_freq = 60
opcache.enable_file_override = 1
opcache.opcache.save_comments = 0


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-26 13:04 UTC] manuel-php at mausz dot at
I managed to get a backtrace:

(gdb) bt
#0  zend_optimize (op_array=op_array@entry=0x149ee28, script=0x143c560, constants=0x7fffffff8c10) at ext/opcache/Optimizer/pass1_5.c:374
#1  0x00007ffff033af41 in zend_accel_optimize (op_array=op_array@entry=0x149ee28, script=script@entry=0x143c560, constants=constants@entry=0x7fffffff8c10) at /root/php-src-PHP-5.6.1/ext/opcache/Optimizer/zend_optimizer.c:524
#2  0x00007ffff033b246 in zend_accel_script_optimize (script=0x143c560, script@entry=<error reading variable: Cannot access memory at address 0x220>) at /root/php-src-PHP-5.6.1/ext/opcache/Optimizer/zend_optimizer.c:587
#3  0x00007ffff0326463 in cache_script_in_shared_memory (from_shared_memory=0x7fffffff8df4, key_length=38, key=0x7ffff0541af4 <accel_globals+372> "/var/www/horde/pear/php/Horde/Util.php", 
    new_persistent_script=<error reading variable: Cannot access memory at address 0x220>) at /root/php-src-PHP-5.6.1/ext/opcache/ZendAccelerator.c:1145
#4  compile_and_cache_file (file_handle=file_handle@entry=0x7fffffff8f30, type=type@entry=2, key=key@entry=0x7ffff0541af4 <accel_globals+372> "/var/www/horde/pear/php/Horde/Util.php", key_length=38, 
    op_array_p=op_array_p@entry=0x7fffffff8df8, from_shared_memory=from_shared_memory@entry=0x7fffffff8df4) at /root/php-src-PHP-5.6.1/ext/opcache/ZendAccelerator.c:1478
#5  0x00007ffff0327962 in persistent_compile_file (file_handle=0x7fffffff8f30, type=2) at /root/php-src-PHP-5.6.1/ext/opcache/ZendAccelerator.c:1655
#6  0x0000000000752230 in compile_filename (type=type@entry=2, filename=filename@entry=0x14945a0) at Zend/zend_language_scanner.l:629
#7  0x000000000082cedb in ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER (execute_data=0x7ffff7fa14e0) at /root/php-src-PHP-5.6.1/Zend/zend_vm_execute.h:31308
#8  0x00000000007f2b08 in execute_ex (execute_data=0x7ffff7fa14e0) at /root/php-src-PHP-5.6.1/Zend/zend_vm_execute.h:363
#9  0x000000000077a83f in zend_call_function (fci=fci@entry=0x7fffffff92f0, fci_cache=0x1467d40, fci_cache@entry=0x7fffffff92c0) at /root/php-src-PHP-5.6.1/Zend/zend_execute_API.c:832
#10 0x00000000007a0fa5 in zend_call_method (object_pp=0x7ffff7fd62c0, obj_ce=<optimized out>, fn_proxy=0x7ffff7fd62b8, function_name=0x13f43e0 "horde_autoloader_default::loadclass\001", function_name_len=<optimized out>, 
    retval_ptr_ptr=retval_ptr_ptr@entry=0x7fffffff93b8, param_count=param_count@entry=1, arg1=0x146e480, arg2=arg2@entry=0x0) at /root/php-src-PHP-5.6.1/Zend/zend_interfaces.c:97
#11 0x00000000006463d7 in zif_spl_autoload_call (ht=<optimized out>, return_value=<optimized out>, return_value_ptr=<optimized out>, this_ptr=<optimized out>, return_value_used=<optimized out>)
    at /root/php-src-PHP-5.6.1/ext/spl/php_spl.c:436
#12 0x000000000077a7a3 in zend_call_function (fci=fci@entry=0x7fffffff9620, fci_cache=fci_cache@entry=0x7fffffff95f0) at /root/php-src-PHP-5.6.1/Zend/zend_execute_API.c:850
#13 0x000000000077b0da in zend_lookup_class_ex (name=name@entry=0x7fffb0589b98 "Horde_Util", name_length=10, key=0x7fffb0e2fcd8, use_autoload=use_autoload@entry=1, ce=ce@entry=0x7fffffff96b8)
    at /root/php-src-PHP-5.6.1/Zend/zend_execute_API.c:1008
#14 0x000000000077b7bd in zend_fetch_class_by_name (class_name=0x7fffb0589b98 "Horde_Util", class_name_len=<optimized out>, key=<optimized out>, fetch_type=0) at /root/php-src-PHP-5.6.1/Zend/zend_execute_API.c:1488
#15 0x00000000007cead4 in ZEND_INIT_STATIC_METHOD_CALL_SPEC_CONST_CONST_HANDLER (execute_data=0x7ffff7fa1200) at /root/php-src-PHP-5.6.1/Zend/zend_vm_execute.h:3826
#16 0x00000000007f2b08 in execute_ex (execute_data=0x7ffff7fa1200) at /root/php-src-PHP-5.6.1/Zend/zend_vm_execute.h:363
#17 0x000000000078b219 in zend_execute_scripts (type=type@entry=8, retval=retval@entry=0x0, file_count=file_count@entry=3) at /root/php-src-PHP-5.6.1/Zend/zend.c:1344
#18 0x000000000072862f in php_execute_script (primary_file=primary_file@entry=0x7fffffffbc60) at /root/php-src-PHP-5.6.1/main/main.c:2584
#19 0x0000000000448ed8 in main (argc=<optimized out>, argv=<optimized out>) at /root/php-src-PHP-5.6.1/sapi/fpm/fpm/fpm_main.c:1949
 [2014-09-26 13:48 UTC] manuel-php at mausz dot at
Hi again

I'm not sure I can reproduce the same issue as ours, but mine is easy to reproduce:

php.ini:
disable_functions = dl

script:
var_dump(is_callable("dl"));
 [2014-09-26 16:36 UTC] manuel-php at mausz dot at
Andre4tw can you retry with https://github.com/manuelm/php-src/commit/1b742a2e9f73c3ae57fbe7939932e22b619ce65e.patch applied?

I no longer get any segfaults. Webserver is primarily running Horde + Roundcube with quite a large user base.
 [2014-09-26 20:58 UTC] andre4tw at gmail dot com
Thank you very much! I´ve tested your patch and it works fine with all my scripts, no crashes anymore. Good job!
 [2014-10-31 09:38 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d9d181e5ad41128a97a6e01d14fb766ff7bf31a8
Log: Fixed Bug #68104 (Segfault while pre-evaluating a disabled function)
 [2014-10-31 09:38 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2014-11-18 20:34 UTC] ab@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d9d181e5ad41128a97a6e01d14fb766ff7bf31a8
Log: Fixed Bug #68104 (Segfault while pre-evaluating a disabled function)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 08:01:29 2024 UTC