Bug #79897 [Opn]: Promoted constructor params with attribs cause crash

From: Date: Sat, 25 Jul 2020 11:38:44 +0000
Subject: Bug #79897 [Opn]: Promoted constructor params with attribs cause crash
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228225@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79897&edit=1 ID: 79897 Updated by: nikic@php.net Reported by: deusekane at gmail dot com Summary: Promoted constructor params with attribs cause crash Status: Open Type: Bug Package: Compile Failure Operating System: Windows PHP Version: 8.0Git-2020-07-25 (Git) Block user comment: N Private report: N New Comment: Same as bug #79878. Previous Comments: ------------------------------------------------------------------------ [2020-07-25 11:15:28] deusekane at gmail dot com The following pull request has been associated: Patch Name: Fixed crash that occurred when a promoted constructor parameter had an attribute On GitHub: https://github.com/php/php-src/pull/5891 Patch: https://github.com/php/php-src/pull/5891.patch ------------------------------------------------------------------------ [2020-07-25 11:14:35] deusekane at gmail dot com Description: ------------ When a class constructor argument has both a visibility modifier and an attribute, and that attribute has at least one argument, the PHP interpreter crashes when attempting to compile it. This is due to the AST node for the attribute being used twice, once to create a parameter attribute and once to create a class property attribute. The linked pull request fixes this bug by creating a temp copy of the attrib AST to use for the class property. https://github.com/php/php-src/pull/5891 Test script: --------------- <?php <<Attribute>> class B { public function __construct($value) { } } class A { public function __construct( <<B(12)>> public $b ) { } } Expected result: ---------------- No output; php parser is able to process the file Actual result: -------------- Crash with ZEND_ASSERTION_FAILED. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79897&edit=1

« previous php.bugs (#228225) next »