Bug #72594 [Ver->Csd]: Calling an earlier instance of an included anonymous class fatals
| From: | laruence@php.net | Date: | Thu, 14 Jul 2016 05:38:57 +0000 |
| Subject: | Bug #72594 [Ver->Csd]: Calling an earlier instance of an included anonymous class fatals | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202295@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72594&edit=1
ID: 72594
Updated by: laruence@php.net
Reported by: php+bug at tubul dot net
Summary: Calling an earlier instance of an included anonymous
class fatals
-Status: Verified
+Status: Closed
Type: Bug
Package: Reproducible crash
Operating System: Linux, Windows
PHP Version: 7.0.8
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=8c5b27e0617bf0899d7e830ed3029711125a0ddb
Log: Fixed bug #72594 (Calling an earlier instance of an included anonymous class fatals)
Previous Comments:
------------------------------------------------------------------------
[2016-07-14 02:02:07] requinix@php.net
Self-contained version: https://3v4l.org/H4q8L
get_object_vars($oldFoo) shows nothing and get_class_methods($oldFoo) shows "bar". Calling
$oldFoo->bar() fatals trying to allocate random amounts of memory. Doing new
ReflectionMethod($oldFoo,"bar") crashes.
Does not happen if $bar is defined after bing().
Moving to Reproducible Crash since it's possible to get one.
------------------------------------------------------------------------
[2016-07-14 01:17:00] php+bug at tubul dot net
Description:
------------
1) get an instance of an anonymous class returned from a included file
2) get another instance of the same class by including it again
3) have the second instance reference the first
-> This gives a fatal error
If in step 2) an exact copy of the file is included instead, the error doesn't happen.
Leaving out the (never used) property of the class also prevents the error.
PHP Version => 7.0.8
Configure Command => './configure'
Server API => Command Line Interface
Test script:
---------------
<?php // test.php
$oldFoo = require('foo.php');
$newFoo = require('foo.php'); // using a copy of foo.php here prevents the error
$newFoo->bing($oldFoo);
<?php // foo.php
return new class{
public $bar; // comment out this line and there is no error
public function bing($foo = null)
{
if ($foo) $foo->bing();
}
};
Now run
php test.php
Expected result:
----------------
There should be no output
Actual result:
--------------
Fatal error: Uncaught Error: Call to undefined method class@anonymous::bing() in
/home/richard/foo.php:6
Stack trace:
#0 /home/richard/test.php(4): class@anonymous->bing(Object(class@anonymous))
#1 {main}
thrown in /home/richard/foo.php on line 6
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72594&edit=1