Bug #81698 [Opn->Fbk]: getType()->getName() crashes on dynamic properties

From: Date: Sun, 05 Dec 2021 18:45:39 +0000
Subject: Bug #81698 [Opn->Fbk]: getType()->getName() crashes on dynamic properties
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238201@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81698&edit=1

 ID:                 81698
 Updated by:         ilutov@php.net
 Reported by:        richiruizmartinez at gmail dot com
 Summary:            getType()->getName() crashes on dynamic properties
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            Reflection related
 Operating System:   Ubuntu 20.04
 PHP Version:        7.4.26
 Block user comment: N
 Private report:     N

 New Comment:

Hm, both examples don't segfault on 3v4l.

https://3v4l.org/fPM7s
https://3v4l.org/2nH6H

Does it require opcache or something to crash? I tried it on master with opcache and it also worked
fine. Can you provide more information about your environment?


Previous Comments:
------------------------------------------------------------------------
[2021-12-04 22:23:52] richiruizmartinez at gmail dot com

getType()->__toString() also crashes:

$foo = new stdClass;
$foo->bar = 1;
var_dump((new ReflectionObject($foo))->getProperties()[0]->getType()->__toString());

------------------------------------------------------------------------
[2021-12-04 17:55:06] richiruizmartinez at gmail dot com

Description:
------------
When I run the code shown below, PHP generates a segmentation fault. The object $o has a dynamic
property $p. When trying to find out the type of $p, the segmentation fault appears.

Test script:
---------------
class C { }
$o = new C();
$o->p = 0;
$ro = new \ReflectionObject($o);
foreach ($ro->getProperties() as $rp) {
   echo $rp->getType()->getName();
}


Expected result:
----------------
segmentation fault (core dumped)



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=81698&edit=1


Thread (1 message)

  • ilutov@php.net
  • Unknown Message
    • ilutov@php.net
« previous php.bugs (#238201) next »