[php-src] Issue #10914: OPCache with Enum and Callback functions results in segmentation fault
| From: | miguelantoniosantos | Date: | Thu, 23 Mar 2023 14:12:56 +0000 |
| Subject: | [php-src] Issue #10914: OPCache with Enum and Callback functions results in segmentation fault | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243987@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10914
Author: miguelantoniosantos
### Description
The following code:
ExampleEnum.php
```php
<?php
enum ExampleEnum: string
{
case FIRST= 'FIRST_VALUE';
}
```
Trigger.php
```php
<?php
function auxiliarFunction(string $enumEntry) {}
function triggerException(callable $callback) {
$callback();
}
function main() {
triggerException(function () {
auxiliarFunction(ExampleEnum::FIRST->value); //This will not run and trigger a SIGSEGV
- core dumped
});
}
```
This was first spotted on Symfony 5.4 codebase, with a callback of the TagAwareCacheInterface.
If OPCache is disabled, the error doesn't occur.
Replacing the enum with a string variable fixes the issue.
### PHP Version
PHP 8.1.11 (fpm-fcgi)
### Operating System
Ubuntu 20.04.5 LTS