|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81208 Segmentation fault while create newInstance from attribute
Submitted: 2021-06-29 19:20 UTC Modified: -
From: saysdragon007 at gmail dot com Assigned:
Status: Closed Package: Reflection related
PHP Version: 8.0.7 OS: MacOS
Private report: No CVE-ID: None
 [2021-06-29 19:20 UTC] saysdragon007 at gmail dot com
I got a segmentation error when I warmed up the cache in Symphony and made a typo in the property argument.
As you can see i pass 3 arguments into Annotation. But If you pass less or more named arguments into annotation or change its order - you got "Expected result".

the annotation  used as reference:

Test script:

class MyAnnotation
    public function __construct(public bool $nullable = false) {}

class MyClass {
    #[MyAnnotation(name: "my_name", type: "integer", nullable: asdasdasd)]
    public $property;

$z = new ReflectionClass(MyClass::class);

foreach($z->getProperty("property")->getAttributes() as $attribute)

Expected result:
Fatal error: Uncaught Error: Undefined constant "asdasdasd" in index.php:18
Stack trace:
#0 index.php(18): ReflectionAttribute->newInstance()
#1 {main}
  thrown in index.php on line 18

Actual result:
zsh: segmentation fault  php index.php


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-07-01 11:38 UTC]
Automatic comment on behalf of nikic
Log: Fixed bug #81208
 [2021-07-01 11:38 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 15 17:01:32 2024 UTC