[php-src] Issue #9968: Segmentation Fault during OPCache Preload in PHP 8.1/PHP8.2
| From: | michdingpayc | Date: | Thu, 17 Nov 2022 20:22:15 +0000 |
| Subject: | [php-src] Issue #9968: Segmentation Fault during OPCache Preload in PHP 8.1/PHP8.2 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242845@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9968
Author: michdingpayc
### Description
Dear PHP Maintainers,
**The following code**, a barebones reproduction is available at https://github.com/michdingpayc/preload-segfault-minimum-reproduction
The problematic preloaded file:
```php
class Root1_Constant_Referencer extends Root2_Empty_Empty
// Removing the extends clause will cause preloading to succeed
// Changing the extends clause to Root1_Constant_Empty will cause preloading to succeed
// Changing the extends clause to a non-existent class will continue causing preloading to segfault
{
protected $propertyReferencingAnExternalConstant = Root1_Constant_Definer::CONSTANT;
// Removing this line will cause preloading to succeed
// Changing this to a hardcoded value will cause preloading to succeed
}
```
preload.php:
```php
echo "Preload started." . PHP_EOL;
$files = require __DIR__ . '/vendor/composer/autoload_classmap.php';
foreach ($files as $file) {
@opcache_compile_file($file);
}
echo "Finished preloading" . PHP_EOL;
```
**Resulted in this output**:
```
$ docker-compose up
Recreating preload-segfault-minimum-reproduction_webpreloader_1 ...
Recreating preload-segfault-minimum-reproduction_webpreloader_1 ... done
Attaching to preload-segfault-minimum-reproduction_webpreloader_1
webpreloader_1 | Preload started.
webpreloader_1 | Finished preloading
preload-segfault-minimum-reproduction_webpreloader_1 exited with code 139
```
**But I expected this output instead**:
(No segmentation Fault. The following output occurs if you comment out the
opcache_compile_file call in preload.php)
```
$ docker-compose up
Starting preload-segfault-minimum-reproduction_webpreloader_1 ...
Starting preload-segfault-minimum-reproduction_webpreloader_1 ... done
Attaching to preload-segfault-minimum-reproduction_webpreloader_1
webpreloader_1 | Preload started.
webpreloader_1 | Finished preloading
webpreloader_1 | Thu Nov 17 18:15:38 2022 (1): Message Cached script '$PRELOAD$'
webpreloader_1 | Thu Nov 17 18:15:38 2022 (1): Message Cached script
'/var/www/html/lib/preload.php'
webpreloader_1 | Thu Nov 17 18:15:38 2022 (1): Message Cached script
'/var/www/html/lib/vendor/composer/autoload_classmap.php'
```
Recommendations attempted: (in all cases the result is the same)
1. Changing base docker image from php:8.1.1-fpm-alpine3.15 to
php:8.1.12-fpm-alpine3.15 and php:8.2-rc-fpm-alpine3.15.
2. Different settings for opcache.jit directive: disable, 0,
0000, 0205, 1205.
3. Setting opcache.jit_buffer_size directive to 0.
Similar to https://github.com/php/php-src/issues/7817
though narrower in scope.
Running the docker-compose command in the linked repository will consistently reproduce the issue.
This is a blocker for our PHP 8.1 migration. Will you please assist?
### PHP Version
PHP 8.1.1 8.1.12 8.2
### Operating System
Docker php:8.1.1-fpm-alpine3.15