Bug #79043 [NEW]: Segmentation fault when using preloading

From: Date: Sun, 29 Dec 2019 15:23:17 +0000
Subject: Bug #79043 [NEW]: Segmentation fault when using preloading
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224588@lists.php.net to get a copy of this message
From:             benjamin dot morel at gmail dot com
Operating system: CentOS 7.7
PHP version:      7.4.1
Package:          opcache
Bug Type:         Bug
Bug description:Segmentation fault when using preloading

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 bug report at https://bugs.php.net/bug.php?id=79043&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79043&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79043&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79043&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79043&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79043&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79043&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79043&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79043&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79043&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79043&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79043&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79043&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79043&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79043&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79043&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79043&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79043&r=mysqlcfg


Thread (19 messages)

« previous php.bugs (#224588) next »