Skip to content

Constants in Enum classes causes php-fpm worker to segfault #8133

Closed
@alshenetsky

Description

@alshenetsky

Description

I have such class:

<?php

namespace App\Domain\TournamentTable;

enum ResultsModifier
{
    case HOME;
    case AWAY;
    case OVERTIME;
    case REGULATION_TIME;
    case OVERALL;
    public const SPECIAL_MODIFIERS = [
        ResultsModifier::AWAY,
        ResultsModifier::HOME,
        ResultsModifier::OVERTIME,
        ResultsModifier::REGULATION_TIME,
    ];
}

When I use this constant in a loop in another class, the php-worker crashes

            foreach (ResultsModifier::SPECIAL_MODIFIERS as $modifier) {
// segfault

Output:

[21-Feb-2022 23:28:26] WARNING: [pool www] child 46 exited on signal 11 (SIGSEGV) after 3.227291 seconds from start

The same code works if I:

  • either turn off opcache (opcache.enable = 0)
  • either remove reference to the constant:
foreach ([ResultsModifier::AWAY, ResultsModifier::HOME, ResultsModifier::OVERTIME, ResultsModifier::REGULATION_TIME] as $modifier) {
// works as expected

So it is probably a bug with opcache.

PHP Version

PHP 8.1.3

Operating System

Alpine 3.13

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions