Edit report at https://bugs.php.net/bug.php?id=79043&edit=1
ID: 79043
Comment by: bugreports at gmail dot com
Reported by: benjamin dot morel at gmail dot com
Summary: Segmentation fault when using preloading
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:
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
Previous Comments:
------------------------------------------------------------------------
[2019-12-29 15:23:17] benjamin dot morel at gmail dot com
Description:
------------
I'm attempting to preload ~3000 PHP classes in my web app, with a simple preloading script that
basically calls opcache_compile_file() on each file contained in Composer's
autoload_classmap.php, minus a few namespaces that contain many files that are rarely used. I'm
including the preload.php script in the "Test script" section here.
When I activate preloading in opcache.ini:
opcache.preload=/path/to/preload.php
I get 503 errors from Apache, that suddenly can't connect to php-fpm.
A quick look at /var/log/php-fpm/error.log shows the following errors:
[29-Dec-2019 16:12:56] NOTICE: [pool nicebooks] child 23191 started
[29-Dec-2019 16:12:56] WARNING: [pool www] child 23182 exited on signal 11 (SIGSEGV) after 0.002705
seconds from start
[29-Dec-2019 16:12:56] NOTICE: [pool www] child 23192 started
[29-Dec-2019 16:12:56] WARNING: [pool www] child 23183 exited on signal 11 (SIGSEGV) after 0.002702
seconds from start
[29-Dec-2019 16:12:56] NOTICE: [pool www] child 23193 started
[29-Dec-2019 16:12:56] WARNING: [pool nicebooks] child 23184 exited on signal 11 (SIGSEGV) after
0.002710 seconds from start
[29-Dec-2019 16:12:56] NOTICE: [pool nicebooks] child 23194 started
[29-Dec-2019 16:12:56] WARNING: [pool nicebooks] child 23185 exited on signal 11 (SIGSEGV) after
0.002746 seconds from start
[29-Dec-2019 16:12:56] NOTICE: [pool nicebooks] child 23196 started
[29-Dec-2019 16:12:56] WARNING: [pool www] child 23186 exited on signal 11 (SIGSEGV) after 0.002733
seconds from start
Looks like all php-fpm workers segfault right after starting with preloading enabled.
I'm not sure how I can provide a minimum reproducible example without giving out the whole
project source.
Test script:
---------------
<?php
// preload.php
$blacklist = [
'Amazon\\ProductAdvertisingAPI\\',
'Aws\\',
'Brick\\Schema\\',
'DTS\\eBaySDK\\',
'Google\\AdsApi\\',
'phpDocumentor\\'
];
$files = require __DIR__ . '/vendor/composer/autoload_classmap.php';
$filtered = [];
foreach ($files as $class => $file) {
foreach ($blacklist as $prefix) {
if (strpos($class, $prefix) === 0) {
continue 2;
}
}
$filtered[$class] = $file;
}
foreach (array_unique($filtered) as $file) {
opcache_compile_file($file);
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79043&edit=1