Bug #79043 [Fbk->Opn]: Segmentation fault when using preloading

From: Date: Tue, 07 Jan 2020 16:09:32 +0000
Subject: Bug #79043 [Fbk->Opn]: Segmentation fault when using preloading
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224757@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79043&edit=1

 ID:                 79043
 Updated by:         nikic@php.net
 Reported by:        benjamin dot morel at gmail dot com
 Summary:            Segmentation fault when using preloading
-Status:             Feedback
+Status:             Open
 Type:               Bug
 Package:            opcache
 Operating System:   CentOS 7.7
 PHP Version:        7.4.1
 Block user comment: N
 Private report:     N

 New Comment:

Thanks for trying the new version! Can you please check whether you already get a crash if you do a
simple "php -d opcache.enable_cli=1 -d opcache.preload=preload.php -r ''"
running from CLI?

And yes, as preloading happens during early server startup, enabling it through php_admin_value does
not work.


Previous Comments:
------------------------------------------------------------------------
[2020-01-07 16:01:12] benjamin dot morel at gmail dot com

Same issue with PHP 7.4.2-RC1, released a few hours ago. Still SIGSEGV.

SIGSEGV only happens when I configure preloading in /etc/php.d/opcache.ini, though:

    opcache.preload=/home/username/example.com/current/preload.php
    opcache.preload_user=username

Everything seems to work fine if I configure it in php-fpm.d instead:

    php_admin_value[opcache.preload] = /home/username/example.com/current/preload.php
    php_admin_value[opcache.preload_user] = username

But even though I can see the configuration being applied (in the Configuration tab of https://github.com/rlerdorf/opcache-status), I
don't measure any performance improvement with preloading enabled.

I'm surprised as this is not in line with the benchmarks I had run a year ago:
https://github.com/composer/composer/issues/7777#issuecomment-440268416

As far as I can tell, it looks like preloading is not in effect when configured this way.

------------------------------------------------------------------------
[2019-12-30 15:13:39] bugreports at gmail dot com

bulding PHP from source is not rocket science, that below needs some adjusting for 7.4 and to build
not only the cli but should be easy to adopt

[builduser@backup-hosting:~]$ rpm -qa | grep devel | sort
glibc-devel-2.17-292.el7.x86_64
keyutils-libs-devel-1.5.8-3.el7.x86_64
krb5-devel-1.15.1-37.el7_7.2.x86_64
libcom_err-devel-1.42.9-16.el7.x86_64
libcurl-devel-7.29.0-54.el7_7.1.x86_64
libicu-devel-50.2-3.el7.x86_64
libselinux-devel-2.5-14.1.el7.x86_64
libsepol-devel-2.5-10.el7.x86_64
libstdc++-devel-4.8.5-39.el7.x86_64
libtool-ltdl-devel-2.4.2-22.el7_3.x86_64
libverto-devel-0.2.5-4.el7.x86_64
libxml2-devel-2.9.1-6.el7_2.3.x86_64
openssl-devel-1.0.2k-19.el7.x86_64
pcre-devel-8.32-17.el7.x86_64
xz-devel-5.2.2-1.el7.x86_64
zlib-devel-1.2.7-18.el7.x86_64

[builduser@backup-hosting:~]$ cat build-php-cli.sh 
#!/usr/bin/bash
PHP_VERSION="7.2.15"
rm -rf /home/builduser/BUILDROOTS/php-$PHP_VERSION
tar xfJ /home/builduser/SOURCES/php-$PHP_VERSION.tar.xz -C /home/builduser/BUILDROOTS/
cd /home/builduser/BUILDROOTS/php-$PHP_VERSION
export CFLAGS="-m64 -Os -mfpmath=sse -mavx -msse2avx -march=native -mtune=native
-ftree-vectorize -fomit-frame-pointer -fno-strict-aliasing -fwrapv -g0"
export CC="gcc $CFLAGS"
export CXXFLAGS="$CFLAGS"
export CPPFLAGS="$CFLAGS"
export CXX="gcc $CFLAGS"
./configure --quiet \
 --host=x86_64-redhat-linux \
 --build=x86_64-redhat-linux \
 --target=x86_64-redhat-linux \
 --prefix=/home/builduser/BUILD \
 --program-prefix= \
 --disable-all \
 --enable-calendar \
 --enable-cli \
 --enable-ctype \
 --enable-dom \
 --enable-filter \
 --enable-hash \
 --enable-intl \
 --enable-json \
 --enable-libxml \
 --enable-mbregex \
 --enable-mbstring \
 --enable-posix \
 --enable-simplexml \
 --enable-soap \
 --enable-static \
 --enable-xml \
 --with-curl \
 --with-iconv \
 --with-layout=GNU \
 --with-openssl \
 --with-pcre-regex \
 --with-system-ciphers \
 --with-zlib \
 --without-apxs2 \
 --without-config-file-path \
 --without-config-file-scan-dir \
 --without-pcre-jit \
 --disable-cgi \
 --disable-dmalloc \
 --disable-dtrace \
 --disable-gcov \
 --disable-ipv6 \
 --disable-phpdbg \
 --disable-rpath \
 --disable-shared \
 --disable-short-tags
make --quiet -j4
make install
strip -s --strip-unneeded /home/builduser/BUILD/bin/php
mv --force /home/builduser/BUILD/bin/php /home/builduser/BINARIES/
rm -rf /home/builduser/BUILD/*
rm -rf /home/builduser/BUILDROOTS/php-$PHP_VERSION
chmod 755 /home/builduser/BINARIES/php
ls /home/builduser/BINARIES/php
echo ""
/home/builduser/BINARIES/php -v
echo ""
/home/builduser/BINARIES/php -m

------------------------------------------------------------------------
[2019-12-30 15:09:05] benjamin dot morel at gmail dot com

It will be hard for me right now to test against 7.4 HEAD. I will wait until 7.4.2 is released and
will report back here.

------------------------------------------------------------------------
[2019-12-29 16:47:09] nikic@php.net

As bugreports@ mentioned, PHP 7.4.1 has quite a few known issues relating to preloading -- lacking
any further context, it is quite likely that the bug you are hitting has already been fixed. If you
can, please test current PHP 7.4 HEAD, or else wait until the 7.4.2 release in January to give this
another try.

If you can send me a set of files that trigger a crash when preloading to nikic@php.net, I can also
try whether I can reproduce this locally.

------------------------------------------------------------------------
[2019-12-29 15:29:05] bugreports at gmail dot com

PHP Version: 7.4.1

this is a bad idea for reporting bugs
https://git.php.net/?p=php-src.git;a=shortlog;h=refs/heads/PHP-7.4

there where ton of fixes in the meantime, many of them affecting preloading

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=79043


--
Edit this bug report at https://bugs.php.net/bug.php?id=79043&edit=1


Thread (19 messages)

« previous php.bugs (#224757) next »