Bug #65168 [Opn]: segfault when __toString() returns "$this"
| From: | laruence@php.net | Date: | Sun, 30 Jun 2013 16:44:09 +0000 |
| Subject: | Bug #65168 [Opn]: segfault when __toString() returns "$this" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-179986@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65168&edit=1
ID: 65168
Updated by: laruence@php.net
Reported by: oliver at x10 dot pe
Summary: segfault when __toString() returns "$this"
Status: Open
Type: Bug
Package: Class/Object related
Operating System: Xubuntu 12.10 64bits
PHP Version: master-Git-2013-06-30 (Git)
Block user comment: N
Private report: N
New Comment:
actually, this is not a "returning" problem,
return "$this" is same as return strval($this),
so, it's the same as return $this->__toString.
it's a stack overflow segfault
Previous Comments:
------------------------------------------------------------------------
[2013-06-30 15:54:07] oliver at x10 dot pe
Description:
------------
Hi,
Casting $this as string inside __toString() magic function makes php crash. It
seems it ran into an infinite loop.
Tested on PHP 5.5 and 5.4.11, even 5.3.6
Test script:
---------------
class base {
function __toString() {
return "$this";
}
}
echo new base();
Expected result:
----------------
Exception thrown, or an error message.
Actual result:
--------------
Violación de segmento (`core' generado)
[Segmentation Fault ('core' dumped)]
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65168&edit=1