`eval` is leaking memory
未关闭
还没有人认领这个 Issue。
Bug
Category: Engine
Status: Needs Triage
- 主要语言
- C
- 星标
- 40.4k
- 派生
- 8.2k
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 96
描述
Description
The following code:
<?php
$m = memory_get_usage();
for ($i = 0; $i < 1000; $i++) {
$fn = eval('return function ($foo) {};');
//$fn = function ($foo) {};
var_dump(memory_get_usage() - $m);
}
https://3v4l.org/LF4Ri
https://3v4l.org/1DeC6 - /wo eval, not leaking
https://3v4l.org/NtIrU - eval /wo anonymous function is not leaking
Resulted in this output:
int(640)
int(672)
int(672)
int(672)
...
int(197280)
But I expected this output instead:
int(640)
int(672)
int(672)
int(672)
...
int(672)
PHP Version
8.1.x
Operating System
any
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行提供的 PHP 8.1 重现代码,并将其内存使用情况与 issue 中链接的 direct-closure 和 eval-without-anonymous-function 示例进行比较。跟踪负责创建匿名函数的 eval 路径;当重复求值不再显示内存使用量持续增加时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- php
- 领域
- compilers, performance
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100