Bug #81208 [NEW]: Segmentation fault while create newInstance from attribute
| From: | saysdragon007 at gmail dot com | Date: | Tue, 29 Jun 2021 19:20:23 +0000 |
| Subject: | Bug #81208 [NEW]: Segmentation fault while create newInstance from attribute | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-234691@lists.php.net to get a copy of this message | ||
From: saysdragon007 at gmail dot com
Operating system: MacOS
PHP version: 8.0.7
Package: Reflection related
Bug Type: Bug
Bug description:Segmentation fault while create newInstance from attribute
Description:
------------
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:
https://github.com/doctrine/orm/blob/2.9.x/lib/Doctrine/ORM/Mapping/Column.php
Test script:
---------------
<?php
#[Attribute(Attribute::TARGET_PROPERTY)]
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)
{
$attribute->newInstance();
}
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
--
Edit bug report at https://bugs.php.net/bug.php?id=81208&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81208&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81208&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81208&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81208&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81208&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81208&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81208&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81208&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81208&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81208&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81208&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81208&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81208&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81208&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81208&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81208&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81208&r=mysqlcfg