ID: 31525
Updated by: [EMAIL PROTECTED]
Reported By: yml at yml dot com
-Status: Open
+Status: Assigned
Bug Type: Zend Engine 2 problem
Operating System: *
PHP Version: 5CVS-2005-03-03
-Assigned To:
+Assigned To: andi
New Comment:
Andi, I think you once responded to similar issue regarding return()
with/without parenthesis..
Previous Comments:
------------------------------------------------------------------------
[2005-03-06 05:55:37] yml at yml dot com
Problem found.
Removing all the ()'s from reference returning functions and the
problem has completely disappeared.
However, the case should be caught by the parser and a warning
generated. Using parens around returns returning references will cause
symbol table corruption occassionally ...
------------------------------------------------------------------------
[2005-03-06 02:43:51] michaels at crye-leike dot com
True, if getThis() is declared to return a reference then everything
works as expected. However, looking through the original reproduce
code I noticed something else. If you add parentheses around $this in
getThis() then the unexpected behavior returns. Complete code:
<?php
class Foo {
function &getThis() {
return ($this);
}
function destroyThis() {
$baz =& $this->getThis();
}
}
$bar = new Foo();
$bar->destroyThis();
var_dump($bar);
?>
Produces:
NULL
Expected:
object(Foo)#1 (0) {
}
------------------------------------------------------------------------
[2005-03-06 01:50:27] yml at yml dot com
Unfortunately the shortened script works as it should if you declare
getThis to return a reference as in
function &getThis()
If however, you refer to the "too-long" script I put together at:
http://www.formvista.com/uploaded_files/php5_drops_object.php.txt
There is something different about it that causes $this to get dropped
even when the method is declared return-by-reference.
I haven't been able to narrow it down but it's entirely possible I'm
overlooking something obvious.
It's got to be something related to legacy pass by reference notation
=&. The strange thing is it worked in 5.0.1 and broke in 5.0.2 or .3.
------------------------------------------------------------------------
[2005-03-06 01:26:05] michaels at crye-leike dot com
FWIW, here's a shorter script that reproduces the problem for me on PHP
5.0.3:
<?php
class Foo {
function getThis() {
return $this;
}
function destroyThis() {
$baz =& $this->getThis();
}
}
$bar = new Foo();
$bar->destroyThis();
var_dump($bar);
?>
This outputs:
NULL
If I change the assign-by-reference operator (=&) to the normal
assignment operator (=) inside destroyThis(), I get:
object(Foo)#1 (0) {
}
Hope this helps...
------------------------------------------------------------------------
[2005-03-03 18:32:24] yml at yml dot com
1. Same problem. No improvement. $this is getting dropped. Used to work
in 5.0RC2. Since 5.0.3 it's been broken.
2. The script I sent was puny. Given how terribly buggy the Zend engine
is, expecting that all serious parser errors can be reproduced in a
total of 20 lines or less is ridiculous. The meat of the script I sent
clearly reproduces the problem in 8 lines, not including the supporting
classes.
You guys wouldn't pull it from my site; and now you won't look at it if
I send it to you. Exactly what would you propose I do to help you track
this down?
The 85,000 lines of code that's actually having this problem (and
producing a coredump), now that's a huge "script".
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/31525
--
Edit this bug report at http://bugs.php.net/?id=31525&edit=1