最新消息:觉得本站不错的话 记得收藏哦 博客内某些功能仅供测试 讨论群:135931704 快养不起小站了 各位有闲钱就打赏下把 My Email weicots#gmail.com Please replace # with @

发现一个 PHP 溢出BUG

PHP ajiang-tuzi 4657浏览
<?php
/**
 * WeiCot Framework
 * User: ajiang
 * WebSite: WWW.WEICOT.COM
 * Date: 2016/6/4 0004
 * Time: 15:31
 * note:bug test
 */
namespace A;
class A
{

    public function  F()
    {

    }

}
namespace B;

use A\A as A;

class B extends A
{

    public function F()
    {

        $this->F();//爆内存错误 死循环

    }
}


$B=new B();
$B->F();

//Fatal error: Allowed memory size of 536870912 bytes
// exhausted (tried to allocate 65488 bytes) 
//in D:\weicot\htdocs\dev\test.php on line 29

正确的写法

<?php
namespace A;
class A
{

    public function  F()
    {

    }

}
namespace B;

use A\A as A;

class B extends A
{

    public function F()
    {

        parent::F();//解决办法

    }
}


$B=new B();
$B->F();

BUG 地址

https://bugs.php.net/bug.php?id=72351

社区给我的Email 中 这样回答的

New Comment:

The first one crashes because you created infinite recursion and PHP ran out of memory before it ran out of stack space.
The second one does not crash because it is not infinite recursion.

Previous Comments:
————————————————————————
[2016-06-07 05:37:04] 1050653098 at qq dot com

转载请注明:(●--●) Hello.My Weicot » 发现一个 PHP 溢出BUG

蜀ICP备15020253号-1