php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77173 include and new anonymous class bug
Submitted: 2018-11-19 05:46 UTC Modified: 2018-11-19 11:37 UTC
Votes:2
Avg. Score:2.5 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: admin at yurunsoft dot com Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: 7.1.24 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: admin at yurunsoft dot com
New email:
PHP Version: OS:

 

 [2018-11-19 05:46 UTC] admin at yurunsoft dot com
Description:
------------
when I include a file, the file new a anonymous class and return, more and more memory usage

Test script:
---------------
<?php
class A
{

}

file_put_contents(__DIR__ . '/tmp.php', '<?php return new class extends A{};');

while(true)
{
	$a = include __DIR__ . '/tmp.php';
	usleep(1000);
}



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-19 07:52 UTC] spam2 at rhsoft dot net
what else do you expect when you include a file in and endless loop?
 [2018-11-19 08:18 UTC] admin at yurunsoft dot com
you can try this code, it's ok!

<?php
class A
{

}

while(true)
{
    $a = new class extends A{};
    usleep(1000);
}
 [2018-11-19 09:54 UTC] spam2 at rhsoft dot net
which proves that it is a bad idea include code in a loop
 [2018-11-19 11:37 UTC] cmb@php.net
I cannot reproduce memory issues with PHP 7.1.24.  Is OPcache or
some other bytecode cache involved?
 [2018-11-20 00:47 UTC] admin at yurunsoft dot com
my extensions:

[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
inotify
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pgsql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
swoole
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
zlib


I use htop to check and find that php's RES is getting higher and higher.
 [2018-11-21 09:49 UTC] wi1dcard dot cn at gmail dot com
Simpler test case:


while(true)
{
    $func = eval('return function () {};');
    var_dump($func);
    unset($func);
    
    usleep(1000);
}
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Thu Dec 13 09:01:26 2018 UTC