Phalcon 3.3.2 + PHP 7.2.5 + Opcache enabled = segmentation fault

When installing phalcon (last version) with php 7.2.5 and opcache enabled, i'm getting randomly segmentation faults.

case:

php -v

PHP 7.2.5 (cli) (built: May 21 2018 12:54:18) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.5, Copyright (c) 1999-2018, by Zend Technologies Segmentation fault

case:

simply visit a url with phpinfo()



78.8k

how did you install phalcon ?

i think there was a weird issue when i compile phalcon with zephir and xdebug was enabled. Try to disable xdebug and re-isntall phalcon. Than enable xdebug.

hi, same issue in production, without xdebug.

production environment:

ab -n 100000 -c 1 -H "Host: www.xxxxx.net" http://127.0.0.1/info.php


info.php:

<?php

phpinfo()

?>


error_log:

[Tue May 22 20:18:30 2018] [notice] child pid 8592 exit signal Segmentation fault (11) [Tue May 22 20:20:06 2018] [notice] child pid 21101 exit signal Segmentation fault (11) [Tue May 22 20:21:06 2018] [notice] child pid 2387 exit signal Segmentation fault (11) [Tue May 22 20:23:05 2018] [notice] child pid 15080 exit signal Segmentation fault (11) [Tue May 22 20:24:07 2018] [notice] child pid 28295 exit signal Segmentation fault (11) [Tue May 22 20:30:07 2018] [notice] child pid 20047 exit signal Segmentation fault (11) [Tue May 22 20:31:12 2018] [notice] child pid 30151 exit signal Segmentation fault (11) [Tue May 22 20:38:07 2018] [notice] child pid 31833 exit signal Segmentation fault (11) [Tue May 22 20:39:07 2018] [notice] child pid 16370 exit signal Segmentation fault (11) [Tue May 22 20:40:07 2018] [notice] child pid 5343 exit signal Segmentation fault (11) [Tue May 22 20:41:06 2018] [notice] child pid 26822 exit signal Segmentation fault (11) [Tue May 22 20:42:06 2018] [notice] child pid 17921 exit signal Segmentation fault (11) [Tue May 22 20:43:11 2018] [notice] child pid 8583 exit signal Segmentation fault (11) [Tue May 22 20:50:07 2018] [notice] child pid 1556 exit signal Segmentation fault (11) [Tue May 22 20:54:06 2018] [notice] child pid 13044 exit signal Segmentation fault (11) [Tue May 22 20:55:09 2018] [notice] child pid 24475 exit signal Segmentation fault (11) [Tue May 22 20:59:07 2018] [notice] child pid 8588 exit signal Segmentation fault (11) [Tue May 22 21:03:20 2018] [notice] child pid 32752 exit signal Segmentation fault (11) [Tue May 22 21:03:27 2018] [notice] child pid 9720 exit signal Segmentation fault (11) [Tue May 22 21:04:06 2018] [notice] child pid 32194 exit signal Segmentation fault (11) [Tue May 22 21:05:06 2018] [notice] child pid 14661 exit signal Segmentation fault (11) [Tue May 22 21:07:40 2018] [notice] child pid 30398 exit signal Segmentation fault (11) [Tue May 22 21:08:12 2018] [notice] child pid 1883 exit signal Segmentation fault (11) [Tue May 22 21:09:11 2018] [notice] child pid 16029 exit signal Segmentation fault (11) [Tue May 22 21:10:38 2018] [notice] child pid 21943 exit signal Segmentation fault (11) [Tue May 22 21:10:59 2018] [notice] child pid 17638 exit signal Segmentation fault (11)

... ...


with phalcon.so disabled:

ab -n 100000 -c 1 -H "Host: www.xxxxx.net" http://127.0.0.1/info.php

error_log:

(none)

edited May '18

Now tested with php 7.2.4, 7.2.3, 7.2.2 with same results, segmentation faults randomly.

Phalcon compiled without xdebug support (disabled xdebug.so before build/install.sh):

[email protected]:/opt/SOURCES/cphalcon/build # php -v PHP 7.2.2 (cli) (built: May 22 2018 21:03:01) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.2, Copyright (c) 1999-2018, by Zend Technologies Segmentation fault

[email protected]:/opt/SOURCES/cphalcon/build # php -m [PHP Modules] bcmath bz2 calendar Core ctype curl date dom exif fileinfo filter ftp gd geoip gettext gmp hash iconv igbinary intl json libxml mbstring memcached mysqli openssl pcntl pcre PDO pdo_mysql pdo_sqlite phalcon Phar posix pspell recode Reflection session SimpleXML SPL sqlite3 standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter Zend OPcache zip zlib

[Zend Modules] Zend OPcache

Segmentation fault

edited May '18

Which OS and web server you use?

Post full gdb - on GitHub.

https://docs.phalconphp.com/en/latest/contributions#bug-report-generating-backtrace

https://github.com/phalcon/cphalcon/issues

If you're by chance using Ubuntu, use this quick guide: https://askubuntu.com/a/947532/564931

edited May '18

using debian 7 and apache 2.2

#0  0x00007f204fa2c892 in zend_accel_script_persist_calc (
    [email protected]=0x7f200b0abec0,
    [email protected]=0x0, [email protected]=0,
    [email protected]=0)
    at /opt/SOURCES/php-7.2.5/ext/opcache/zend_persist_calc.c:416
#1  0x00007f204fa20473 in store_script_in_file_cache (
    new_persistent_script=0x7f200b0abec0)
    at /opt/SOURCES/php-7.2.5/ext/opcache/ZendAccelerator.c:1264
#2  0x00007f204fc80bc0 in ?? () from /opt/php/lib/extension/opcache.so
#3  0x00000000021d7b80 in ?? ()
#4  0x00007f204fa203f0 in ?? ()
    at /opt/SOURCES/php-7.2.5/Zend/zend_string.h:291
   from /opt/php/lib/extension/opcache.so
#5  0x00007f204fa20131 in accel_copy_permanent_strings (
    new_interned_string=0x7f200b0abec0,
    [email protected]=0x7f204fa203f0 <accel_replace_string_by_process_permanent>) at /opt/SOURCES/php-7.2.5/ext/opcache/ZendAccelerator.c:580
#6  0x00007f204fa235f4 in accel_use_permanent_interned_strings ()
    at /opt/SOURCES/php-7.2.5/ext/opcache/ZendAccelerator.c:665
#7  accel_shutdown ()
    at /opt/SOURCES/php-7.2.5/ext/opcache/ZendAccelerator.c:2796
#8  0x00007f204fa26500 in zm_shutdown_zend_accelerator (
    type=<optimized out>, module_number=<optimized out>)
    at /opt/SOURCES/php-7.2.5/ext/opcache/zend_accelerator_module.c:434
#9  0x00007f20530f4453 in module_destructor ([email protected]=0x257c090)
    at /opt/SOURCES/php-7.2.5/Zend/zend_API.c:2564
#10 0x00007f20530ec0ac in module_destructor_zval (zv=<optimized out>)
    at /opt/SOURCES/php-7.2.5/Zend/zend.c:690
#11 0x00007f20530ff7ce in _zend_hash_del_el_ex (prev=<optimized out>,
    p=<optimized out>, idx=<optimized out>, ht=<optimized out>)
    at /opt/SOURCES/php-7.2.5/Zend/zend_hash.c:996
#12 _zend_hash_del_el (p=<optimized out>, idx=52, ht=0x7f2053ad92a0)
    at /opt/SOURCES/php-7.2.5/Zend/zend_hash.c:1019
#13 zend_hash_graceful_reverse_destroy ([email protected]=0x7f2053ad92a0)
    at /opt/SOURCES/php-7.2.5/Zend/zend_hash.c:1475
#14 0x00007f20530f25dc in zend_destroy_modules ()
    at /opt/SOURCES/php-7.2.5/Zend/zend_API.c:2008
#15 0x00007f20530ed82e in zend_shutdown ()
    at /opt/SOURCES/php-7.2.5/Zend/zend.c:905
#16 0x00007f205308ad0b in php_module_shutdown ()
    at /opt/SOURCES/php-7.2.5/main/main.c:2453
#17 0x00007f205308adc9 in php_module_shutdown_wrapper (
    sapi_globals=<optimized out>) at /opt/SOURCES/php-7.2.5/main/main.c:2426
#18 0x00007f20531972e1 in php_apache_child_shutdown (tmp=<optimized out>)
    at /opt/SOURCES/php-7.2.5/sapi/apache2handler/sapi_apache2.c:424
#19 0x00007f205c26ddbe in run_cleanups (cref=<optimized out>)
    at memory/unix/apr_pools.c:2352
#20 apr_pool_destroy (pool=0x25951f8) at memory/unix/apr_pools.c:814
#21 0x000000000045090e in clean_child_exit ([email protected]=0)
    at prefork.c:196
#22 0x0000000000450d9e in child_main ([email protected]=50)
    at prefork.c:692
#23 0x000000000045136c in make_child (slot=50, s=0x17c9860) at prefork.c:768
#24 make_child (s=0x17c9860, slot=50) at prefork.c:696
#25 0x0000000000451eb2 in perform_idle_server_maintenance (p=<optimized out>)
    at prefork.c:903
#26 ap_mpm_run ([email protected]=0x17c4138, plog=<optimized out>,
    [email protected]=0x17c9860) at prefork.c:1107
#27 0x000000000042a031 in main (argc=5, argv=0x7ffeb8e40f78) at main.c:753

The problem appears related with opcache/zend_persist_calc.c



78.8k
edited May '18

probably related to https://bugs.php.net/bug.php?id=76337 unfortunatly the fix will be released with 7.2.7 rather than with 7.2.6.

//edit

just did a test with apache utils as yours. ab -n 100000 -c 1 -H and my error log is empty, i am usling like 20 php extensions.

ubuntu 18.04, php 7.2.5 with nginx fpm

@jcastilloa Could you please open an issue at cphalcon GitHub repo with steps to reproduce and all relevant information. We'll try to sort out