ID:               45467
 Updated by:       [EMAIL PROTECTED]
 Reported By:      thijs dot wijnmaalen at gmail dot com
 Status:           Verified
 Bug Type:         Scripting Engine problem
 Operating System: *
 PHP Version:      5.2CVS, 5.3CVS (2008-07-09)
 New Comment:

> return $this->$this->_[0]();

Here PHP will try to read the property $this->$this. So it will try to
convert $this to a string, which will call __toString(), etc and it
crashes.

This is basically the same as the following code:
<?php
class A {
        function __toString() {
                return (string)$this;
        }
}
echo $a = new A;
?>



Previous Comments:
------------------------------------------------------------------------

[2008-07-10 10:27:22] [EMAIL PROTECTED]

It actually crashes, here's relevant part from valgrind:

==1178== Process terminating with default action of signal 11
(SIGSEGV)
==1178==  Access not within mapped region at address 0xBE1A0FFC
==1178==    at 0x823AF25: zend_get_property_info
(zend_object_handlers.c:179)
==1178== Stack overflow in thread 1: can't grow stack to 0xBE1A0FF8

And this is the gdb output (relevant parts):

execute (op_array=0x8aad87c) at
/home/jani/src/php-5.2/Zend/zend_vm_execute.h:53
53              memset(EX(CVs), 0, sizeof(zval**) *
op_array->last_var);

The full backtrace is a bit too long to paste here.


------------------------------------------------------------------------

[2008-07-09 13:28:01] thijs dot wijnmaalen at gmail dot com

Description:
------------
When accessing a method within or from another class, whereby the name

is stored as value in an array as attribute in the class.

The proper way of doing this would be to enclose the method name in 
brackets (which works as expected):

return $this->{$this->_[0]}();




Reproduce code:
---------------
<?php

class A {
        private $_ = array();
        function __toString () {
                $this->_[0] = 'a';
                return $this->$this->_[0]();
        }
        
        function a () {
                return 'call';
        }
}

echo $a = new A();

?>

Expected result:
----------------
Syntax error message

Actual result:
--------------
Empty reply from server


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45467&edit=1

Reply via email to