Skip to content

Php 8.4 - ReflectionProperty->getHooks() on dynamic property results in segmentation fault #15718

Closed

Description

@bkdotcom

Description

The following code:

https://3v4l.org/nurSR/rfc#vgitmaster

<?php

#[\AllowDynamicProperties]
class SegFault
{
}

$segFault = new SegFault();
$segFault->dynamicProp = 'dont call getHooks!';

$reflectionProperty = new ReflectionProperty($segFault, 'dynamicProp');

$reflectionProperty->getHooks();

Resulted in this output:

Segmentation fault: 11

But I expected this output instead:

¯\_(ツ)_/¯
getHooks should return an empty array
perhaps throw an exception on a dynamic property
definitely not segFault

PHP Version

PHP 8.4 2024-09-03

Operating System

osx & 3v4l.org

Activity

  1. ndossche commented on Sep 3, 2024

    @ndossche
    Member

    Intuitively, I suspect that ref->prop is NULL, which also means that getHook has the same problem.
    But I'm on mobile rn and can't check.

  2. DanielEScherzer commented on Sep 3, 2024

    @DanielEScherzer
    Member

    Its not just with #[\AllowDynamicProperties], but also when using stdClass, or even classes that don't allow dynamic and thus issue a warning while still being used.

    Its also not just getHooks(), but also getHook(), with this issue

  3. DanielEScherzer commented on Sep 3, 2024

    @DanielEScherzer
    Member

    PR at #15721, I don't seem to have the rights to link it as closing this issue

  4. added a commit that references this issue on Sep 3, 2024
    e3e80f6
  5. iluuu1994 commented on Sep 3, 2024

    @iluuu1994
    Member
  6. added a commit that references this issue on Sep 3, 2024
    18df69e
  7. bkdotcom commented on Sep 4, 2024

    @bkdotcom
    Author

    Early adoption for the win!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions