Skip to content

jit bug & segfault with symfony lazyghosttrait #13508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
verfriemelt-dot-org opened this issue Feb 25, 2024 · 3 comments · Fixed by #13610
Closed

jit bug & segfault with symfony lazyghosttrait #13508

verfriemelt-dot-org opened this issue Feb 25, 2024 · 3 comments · Fixed by #13610
Assignees

Comments

@verfriemelt-dot-org
Copy link

verfriemelt-dot-org commented Feb 25, 2024

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

@k0d3r1s
Copy link

k0d3r1s commented Feb 26, 2024

I have the same problem with php 8.2.7

@verfriemelt-dot-org
Copy link
Author

verfriemelt-dot-org commented Mar 1, 2024

i updated the repository to pin the symfony/var-exporter 7.0.3 package to reproduce the issue.

@arnaud-lb arnaud-lb self-assigned this Mar 6, 2024
arnaud-lb added a commit that referenced this issue Mar 11, 2024
* PHP-8.2:
  [ci skip] NEWS
  Fix GH-13508: JITed QM_ASSIGN may be optimized out when op1 is null (#13610)
arnaud-lb added a commit that referenced this issue Mar 11, 2024
* PHP-8.3:
  [ci skip] NEWS
  [ci skip] NEWS
  Fix GH-13508: JITed QM_ASSIGN may be optimized out when op1 is null (#13610)
@arnaud-lb
Copy link
Member

Fixed in 8.2 and 8.3.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants