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/fPM7shttps://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