Skip to content

jit bug & segfault with symfony lazyghosttrait #13508

Closed
@verfriemelt-dot-org

Description

@verfriemelt-dot-org

Description

heyho,

I noticed some odd behaviour with php and jit enabled while working with symfonys lazyghosttrait. Given the sample code here: https://github.com/verfriemelt-dot-org/lazyghost-trait-bug
when you run php with opcache.jit=tracing id produces bugs and with opcache.jit=function it works as expected, see make function and make tracing running and ouputting results for both examples

the php jit settings i set:

opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=256M
opcache.jit=on

the code which behaves erratically is this one: https://github.com/symfony/symfony/blob/7.1/src/Symfony/Component/VarExporter/Internal/Hydrator.php#L265

            if (\ReflectionProperty::IS_PRIVATE & $flags) {
                $propertyScopes["\0$class\0$name"] = $propertyScopes[$name] = [$class, $name, $flags & \ReflectionProperty::IS_READONLY ? $class : null, $property];
                continue;
            }

with make function:

 private const LAZY_OBJECT_PROPERTY_SCOPES = [
     "\0".parent::class."\0".'apps' => [parent::class, 'apps', null],
     "\0".parent::class."\0".'code' => [parent::class, 'code', null],

with make tracing:

 private const LAZY_OBJECT_PROPERTY_SCOPES = [
     "\0".parent::class."\0".'apps' => [parent::class, 'apps', 'apps'],
     "\0".parent::class."\0".'code' => [parent::class, 'code', 'code'],

also altering / adding code like

            if (\ReflectionProperty::IS_PRIVATE & $flags) {
                $propertyScopes["\0$class\0$name"] = $propertyScopes[$name] = [$class, $name, $flags & \ReflectionProperty::IS_READONLY ? $class : null, $property];
                var_dump([$class, $name, $flags & \ReflectionProperty::IS_READONLY ? $class : null, $property]);
                continue;
            }

results in inconsitent behaviour, mostly segfaults but also sometimes other errors like for example:

[critical] Error thrown while running command "'ca:warm'". Message: "Type "ReflectionProperty" is not instantiable."

In Registry.php line 108:

  Type "ReflectionProperty" is not instantiable.


In Registry.php line 106:

  Symfony\Component\Console\EventListener\ErrorListener

symfony issue describing the problem too: symfony/symfony#54053

PHP Version

8.3.3

Operating System

linux

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions