Edit report at https://bugs.php.net/bug.php?id=63132&edit=1
ID: 63132 Updated by: ni...@php.net Reported by: ni...@php.net Summary: Generators do not back up argument type stack -Status: Open +Status: Closed Type: Bug Package: Scripting Engine problem PHP Version: 5.4Git-2012-09-21 (Git) Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikic Revision: http://git.php.net/?p=php-src.git;a=commit;h=a31fa55b44bcb342c00e9ab2f4a851d054897a39 Log: Fixed bug #63132 Previous Comments: ------------------------------------------------------------------------ [2012-09-21 14:53:18] ni...@php.net 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 this bug report at https://bugs.php.net/bug.php?id=63132&edit=1