summaryrefslogtreecommitdiff
path: root/Zend/tests/generators
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2013-06-29 21:51:54 +0200
committerNikita Popov <nikic@php.net>2013-06-29 21:51:54 +0200
commit0f36224beb61b8d0b189c447bdb44ee2d73be637 (patch)
treecb5137f47c59be6c0c6884fa74214601dad9666d /Zend/tests/generators
parent5904da994803d2f9a70a0cb4675ebd9eeb9bce54 (diff)
downloadphp-git-0f36224beb61b8d0b189c447bdb44ee2d73be637.tar.gz
Don't try to clean up generator stack on unclean shutdown
This fixes bugs #65035 and #65161. In one of the bugs the issue is that function_state.arguments is NULL, but the arg count is pushed to the stack and the code tries to free it. In the other bug the stack of the generator is freed twice, once in generator_close and later during shutdown. It's rather hard (if at all possible) to do a proper stack cleanup on an unclean shutdown, so I'm just disabling it in this case.
Diffstat (limited to 'Zend/tests/generators')
-rw-r--r--Zend/tests/generators/bug65035.phpt20
-rw-r--r--Zend/tests/generators/bug65161.phpt20
2 files changed, 40 insertions, 0 deletions
diff --git a/Zend/tests/generators/bug65035.phpt b/Zend/tests/generators/bug65035.phpt
new file mode 100644
index 0000000000..18276cc23a
--- /dev/null
+++ b/Zend/tests/generators/bug65035.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #65035: yield / exit segfault
+--FILE--
+<?php
+
+function gen() {
+ fn();
+ yield;
+}
+
+function fn() {
+ exit('Done');
+}
+
+$gen = gen();
+$gen->current();
+
+?>
+--EXPECT--
+Done
diff --git a/Zend/tests/generators/bug65161.phpt b/Zend/tests/generators/bug65161.phpt
new file mode 100644
index 0000000000..215c1880e3
--- /dev/null
+++ b/Zend/tests/generators/bug65161.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug #65161: Generator + autoload + syntax error = segfault
+--FILE--
+<?php
+
+function autoload() {
+ foo();
+}
+spl_autoload_register('autoload');
+
+function testGenerator() {
+ new SyntaxError('param');
+ yield;
+}
+
+foreach (testGenerator() as $i);
+
+?>
+--EXPECTF--
+Fatal error: Call to undefined function foo() in %s on line %d