cphalcon: 3.4.3 segfaults with PHP 7.3.6 (but not 7.3.5) and OPcache

Having cphalcon 3.4.3 enabled in PHP 7.3.6 together with OPcache leads to a segmentation fault somewhere during engine or request shutdown - scripts etc run fine, but PHP segfaults before exiting:

$ php -v
PHP 7.3.6 (cli) (built: May 30 2019 14:55:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.6, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.6, Copyright (c) 1999-2018, by Zend Technologies
Segmentation fault

Disabling phalcon, or disabling opache, fixes the issue.

The crash does not occur on 7.3.5, which makes me think it’s related to OPcache changes in 7.3.6 the changelog describes as “fixed possible crashes, because of inconsistent PCRE cache and opcache SHM reset.”

I can’t rebuild everything as debug builds at the moment and provide core dumps etc, so I’m hoping y’all can reproduce and diagnose this more easily than me.

Details

$ php --ri phalcon

phalcon

Web framework delivered as a C-extension for PHP
phalcon => enabled
Author => Phalcon Team and contributors
Version => 3.4.3
Build Date => Mar  8 2019 15:07:32
Powered by Zephir => Version 0.10.14-975ad02db4

Directive => Local Value => Master Value
phalcon.db.escape_identifiers => On => On
phalcon.db.force_casting => Off => Off
phalcon.orm.events => On => On
phalcon.orm.virtual_foreign_keys => On => On
phalcon.orm.column_renaming => On => On
phalcon.orm.not_null_validations => On => On
phalcon.orm.exception_on_failed_save => Off => Off
phalcon.orm.enable_literals => On => On
phalcon.orm.late_state_binding => Off => Off
phalcon.orm.enable_implicit_joins => On => On
phalcon.orm.cast_on_hydrate => Off => Off
phalcon.orm.ignore_unknown_columns => Off => Off
phalcon.orm.update_snapshot_on_save => On => On
phalcon.orm.disable_assign_setters => Off => Off
Segmentation fault
$ php -i
phpinfo()
PHP Version => 7.3.6

System => Linux f94a1774-dc9b-47b5-b3bf-6b2007d6deb8 4.4.0-1044-aws #47-Ubuntu SMP Wed May 8 19:02:36 UTC 2019 x86_64
Build Date => May 30 2019 14:52:51
Configure Command =>  './configure'  '--prefix=/app/.heroku/php' '--with-config-file-path=/app/.heroku/php/etc/php' '--with-config-file-scan-dir=/app/.heroku/php/etc/php/conf.d' '--disable-phpdbg' '--enable-fpm' '--with-bz2' '--with-curl' '--with-pdo-mysql' '--with-mysqli' '--with-openssl' '--with-kerberos' '--with-pgsql' '--with-pdo-pgsql' '--with-readline' '--enable-sockets' '--enable-zip' '--with-zlib' '--enable-bcmath=shared' '--enable-calendar=shared' '--enable-exif=shared' '--enable-ftp=shared' '--with-gd=shared' '--with-freetype-dir=/usr' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-gettext=shared' '--with-gmp=shared' '--with-imap=shared,/app/.heroku/php/opt/imap-2007f' '--with-imap-ssl' '--enable-intl=shared' '--with-ldap=shared' '--with-ldap-sasl' '--enable-mbstring=shared' '--enable-pcntl=shared' '--enable-shmop=shared' '--enable-soap=shared' '--with-sqlite3=shared' '--with-pdo-sqlite=shared' '--with-xmlrpc=shared' '--with-xsl=shared' '--enable-opcache-file' '--without-libzip' '--with-sodium=shared'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /app/.heroku/php/etc/php
Loaded Configuration File => /app/.heroku/php/etc/php/php.ini
Scan this dir for additional .ini files => /app/.heroku/php/etc/php/conf.d
Additional .ini files parsed => /app/.heroku/php/etc/php/conf.d/000-heroku.ini,
/app/.heroku/php/etc/php/conf.d/010-ext-zend_opcache.ini,
/app/.heroku/php/etc/php/conf.d/100-ext-bcmath.ini,
/app/.heroku/php/etc/php/conf.d/110-ext-calendar.ini,
/app/.heroku/php/etc/php/conf.d/120-ext-intl.ini,
/app/.heroku/php/etc/php/conf.d/130-ext-mbstring.ini,
/app/.heroku/php/etc/php/conf.d/140-ext-xmlrpc.ini,
/app/.heroku/php/etc/php/conf.d/150-ext-phalcon.ini,
/app/.heroku/php/etc/php/conf.d/160-ext-redis.ini
…
Segmentation fault

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 31 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Phalcon v3.4.4 was released.

That doesn’t make any sense. If it’s supported long term … we need this fix. Currently 3.4.3 is broken with latest PHP … LTS can make point builds all the time … just cut a new release. and rebuild so packagecloud is updated and then ondrej’s PPAs will update and same with Remi’s.

diff --git a/ext/kernel/main.c b/ext/kernel/main.c
index c940e0e26..c14e24a36 100644
--- a/ext/kernel/main.c
+++ b/ext/kernel/main.c
@@ -389,10 +389,20 @@ int zephir_declare_class_constant(zend_class_entry *ce, const char *name, size_t
 {
 #if PHP_VERSION_ID >= 70100
        int ret;
+       zend_string *key;
+
+       if (ce->type == ZEND_INTERNAL_CLASS) {
+               key = zend_string_init_interned(name, name_length, 1);
+       } else {
+               key = zend_string_init(name, name_length, 0);
+       }
 
-       zend_string *key = zend_string_init(name, name_length, ce->type & ZEND_INTERNAL_CLASS);
        ret = zend_declare_class_constant_ex(ce, key, value, ZEND_ACC_PUBLIC, NULL);
-       zend_string_release(key);
+
+       if (ce->type != ZEND_INTERNAL_CLASS) {
+               zend_string_release(key);
+       }
+
        return ret;
 #else
        if (Z_CONSTANT_P(value)) {

If the timeline for 4.x has shifted since the LTS announcement was made, then maybe the LTS timeline should also be adjusted accordingly.

I understand the desire to not have too much code to maintain in parallel, but the fact is that right now, the latest stable release does not work on the latest stable PHP version, which contains security fixes.

And IMHO, even if 4.x had been released recently, a 3.4.4 would still be necessary. Users can’t simply upgrade to a major new framework version overnight. This sort of predictability and reliability is important for a framework; otherwise, people can’t rely on it, if they have to risk the foundation of their projects to become abandonware without a suitable replacement.

For 4.x, I propose the LTS strategy to be something like “bug fixes for six months after 5.0.0 is released, security fixes for another six months after that”, or similar.

And of course, I can simply rebuild Phalcon/Zephir from source (already did that two weeks ago and rolled it out on Heroku; https://devcenter.heroku.com/changelog-items/1651), but as a downstream maintainer, I want to provide standard package releases to users, not custom builds with a bunch of patches on top.

We will sort this out this weekend - try to build DLLs also.

It was our mistake that we did not add the LTS note and duration in the documentation in its own page so that all can refer to that. Our announcement was 3 years LTS for the v3 which is en par or more than the average LTS of packages.

Having written that, 3 years have passed, Just because something is LTS does not mean that it is maintained forever. For the argument well there is no v4 to upgrade, that is evident. My point is just because a new version has not been released yet, does not necessarily mean that the LTS time defined will be extended indefinitely or otherwise.

Just a few thoughts.

+1 for 3.4.4 with this fix

And until 4.0 is any kind of proven stable final (no alpha, no beta) there is no other official running and supported version than 3.4.3 at the moment which people (at least serious managers) will approve for usage in a production environment. That said, if no 3.4.x version is officially provided having this fixed for the latest php version, I smell people saying to abandon phalcon and go back to a raw php framework again. (we had the dicussion before some months ago and it was a very good decision by you to, in the end, officially provide 3.4.3 for all platforms back then 👍🏻) Phalcon 4.x stable final will still take many more months I guess, and that cannot mean you want your users being stuck at old php versions or force them to use either 4. 0 alpha/beta versions (which require adjusting of their code anyway) or compile the stuff on their own (and unfortunately there are not only Linux and Mac users) Please take a deep breath and think about it again 🙂 thank you 😉

Thanks Niden … all we need is just a 3.4.4 release - it’s super easy and just allows for downstream maintainers to properly build packages. Code, I believe, is already merged. So just tag/release and run appropriate release stuff.

The 3.x branch is not longer supported (it was LTS).

How is it possible ? 3.4.3 is the LATEST released version.

I apologize @dzuelke for completely overlooking this.

Just regenerated C-code for Phalcon’s 3.4.x branch:

* 4d7e9a9f6 | Thu Jun 27 22:08:30 2019 | Bump version (HEAD -> 3.4.x, origin/3.4.x) [Serghei Iakovlev]
* 0316216d2 | Thu Jun 27 22:07:19 2019 | Regenerated build (PHP7) [Serghei Iakovlev]
* 9d4a4af02 | Thu Jun 27 22:01:11 2019 | Regenerated build (PHP5) [Serghei Iakovlev]
* b517269a9 | Thu Jun 27 22:00:36 2019 | Use latest Zephir from 0.10.x branch [Serghei Iakovlev]

You can try new Phalcon using command as follows:

$ git clone --depth=1 --branch=3.4.x https://github.com/phalcon/cphalcon.git
$ cd cphalcon/build
$ sudo ./install

# If you have specific php versions running
$ sudo ./install --phpize /usr/bin/phpize5.6 --php-config /usr/bin/php-config5.6

Thanks for catching this bug, and I am sorry about the delay. I hope it fixed now. I’m closing this issue but if I have made an oversight, please do get back in touch.

I’ll regenerate the build for 3.4.x in next days. Could someone ping me if I forget to do this