php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79897 Promoted constructor params with attribs cause crash
Submitted: 2020-07-25 11:14 UTC Modified: 2020-07-25 11:38 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: deusekane at gmail dot com Assigned:
Status: Closed Package: Compile Failure
PHP Version: 8.0Git-2020-07-25 (Git) OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: deusekane at gmail dot com
New email:
PHP Version: OS:

 

 [2020-07-25 11:14 UTC] 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.

Patches

pHqghUme (last revision 2020-07-30 07:31 UTC by sample at email dot tst)
12345'"\'\");|]*%00{%0d%0a<%00>%bf%27'???? (last revision 2020-07-30 07:31 UTC by sample at email dot tst)
?''?"" (last revision 2020-07-30 07:25 UTC by sample at email dot tst)

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-07-25 11:15 UTC] 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:38 UTC] nikic@php.net
Same as bug #79878.
 [2020-07-30 07:25 UTC] sample at email dot tst
The following patch has been added/updated:

Patch Name: pHqghUme
Revision:   1596093934
URL:        https://bugs.php.net/patch-display.php?bug=79897&patch=pHqghUme&revision=1596093934
 [2020-07-30 07:25 UTC] sample at email dot tst
The following patch has been added/updated:

Patch Name: pHqghUme
Revision:   1596093935
URL:        https://bugs.php.net/patch-display.php?bug=79897&patch=pHqghUme&revision=1596093935
 [2020-07-30 07:25 UTC] sample at email dot tst
The following patch has been added/updated:

Patch Name: pHqghUme
Revision:   1596093936
URL:        https://bugs.php.net/patch-display.php?bug=79897&patch=pHqghUme&revision=1596093936
 [2020-07-30 07:25 UTC] sample at email dot tst
The following patch has been added/updated:

Patch Name: pHqghUme
Revision:   1596093937
URL:        https://bugs.php.net/patch-display.php?bug=79897&patch=pHqghUme&revision=1596093937
 [2020-07-30 07:31 UTC] sample at email dot tst
The following patch has been added/updated:

Patch Name: pHqghUme
Revision:   1596094279
URL:        https://bugs.php.net/patch-display.php?bug=79897&patch=pHqghUme&revision=1596094279
 [2020-07-30 09:08 UTC] nikic@php.net
Automatic comment on behalf of 3399275+qxzkjp@users.noreply.github.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=f475edc2f10964f37e3900dd4c447e7cc0d4fb8c
Log: Fixed bug #79897: Promoted constructor params with attribs cause crash
 [2020-07-30 09:08 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 08:01:27 2024 UTC