Bug #81208 [Opn->Csd]: Segmentation fault while create newInstance from attribute

From: Date: Thu, 01 Jul 2021 11:38:22 +0000
Subject: Bug #81208 [Opn->Csd]: Segmentation fault while create newInstance from attribute
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234721@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81208&edit=1 ID: 81208 Updated by: git@php.net Reported by: saysdragon007 at gmail dot com Summary: Segmentation fault while create newInstance from attribute -Status: Open +Status: Closed Type: Bug Package: Reflection related Operating System: MacOS PHP Version: 8.0.7 Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikic Revision: https://github.com/php/php-src/commit/b976bc44f16fa34450bf92345067b267c52cd7ee Log: Fixed bug #81208 Previous Comments: ------------------------------------------------------------------------ [2021-06-29 19:20:23] saysdragon007 at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=81208&edit=1

« previous php.bugs (#234721) next »