Bug #63132 [NEW]: Generators do not back up argument type stack
| From: | nikic@php.net | Date: | Fri, 21 Sep 2012 14:53:18 +0000 |
| Subject: | Bug #63132 [NEW]: Generators do not back up argument type stack | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-173618@lists.php.net to get a copy of this message | ||
From: nikic
Operating system:
PHP version: 5.4Git-2012-09-21 (Git)
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Generators do not back up argument type stack
Description:
------------
As reported by dmitry in https://bugs.php.net/bug.php?id=63066 there
currently are issues with yield interruptions in nested method calls.
The following code:
<?php
class A {
function foo() {
echo "Called A::foo\n";
}
}
class B {
function foo() {
echo "Called B::foo\n";
}
}
function gen($obj) {
$obj->foo($obj->foo(yield));
}
$g1 = gen(new A);
$g1->current();
$g2 = gen(new B);
$g2->current();
$g1->next();
Will output:
Called A::foo
Called B::foo
[Fri Sep 21 16:49:14 2012] Script: '/home/nikic/dev/php-src/t26.php'
/home/nikic/dev/php-src/Zend/zend_vm_execute.h(949) : Freeing 0xB77579F0
(20 bytes), script=/home/nikic/dev/php-src/t26.php
=== Total 1 memory leaks detected ===
The issue is that generators currently only back up the argument stack (the
main VM stack), but don't back up the argument type stack
EG(arg_types_stack). This stack contains object and fbc.
So when two generators with nested method calls are intermixed the VM mixes
up the different objects/fbcs (and if a generator is closed during the
nested method call the object leaks).
--
Edit bug report at https://bugs.php.net/bug.php?id=63132&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63132&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63132&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63132&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63132&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=63132&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63132&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63132&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63132&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63132&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63132&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=63132&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=63132&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63132&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63132&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63132&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63132&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63132&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63132&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63132&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63132&r=mysqlcfg