summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-06-08 11:31:28 +0200
committerDerick Rethans <github@derickrethans.nl>2020-06-08 11:31:19 +0100
commite2d25c5a854023c4cf5d09b15d63e64cd4b7ceda (patch)
tree76a3a3b38157163b4b82cdf1c47566fa346be2bf
parent33229a1a59a9ca8e0873f3f69b6d5e10eba8ee7f (diff)
downloadphp-git-e2d25c5a854023c4cf5d09b15d63e64cd4b7ceda.tar.gz
Cherry pick fix for #79657
-rw-r--r--NEWS5
-rw-r--r--Zend/tests/bug79657.phpt42
-rw-r--r--Zend/zend_generators.c1
3 files changed, 45 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 63dadd4183..99e47640d9 100644
--- a/NEWS
+++ b/NEWS
@@ -2,15 +2,14 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 7.4.7
-
-28 May 2020, PHP 7.4.7RC1
-
- Core:
. Fixed bug #79599 (coredump in set_error_handler). (Laruence)
. Fixed bug #79566 (Private SHM is not private on Windows). (cmb)
. Fixed bug #79489 (.user.ini does not inherit). (cmb)
. Fixed bug #79600 (Regression in 7.4.6 when yielding an array based
generator). (Nikita)
+ . Fixed bug #79657 ("yield from" hangs when invalid value encountered).
+ (Nikita)
- FFI:
. Fixed bug #79571 (FFI: var_dumping unions may segfault). (cmb)
diff --git a/Zend/tests/bug79657.phpt b/Zend/tests/bug79657.phpt
new file mode 100644
index 0000000000..fb2ccab3e3
--- /dev/null
+++ b/Zend/tests/bug79657.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Bug #79657: "yield from" hangs when invalid value encountered
+--FILE--
+<?php
+
+function throwException(): iterable
+{
+ throw new Exception();
+}
+
+function loop(): iterable
+{
+ $callbacks = [
+ function () {
+ yield 'first';
+ },
+ function () {
+ yield from throwException();
+ }
+ ];
+
+ foreach ($callbacks as $callback) {
+ yield from $callback();
+ }
+}
+
+function get(string $first, int $second): array
+{
+ return [];
+}
+
+get(...loop());
+
+?>
+--EXPECTF--
+Fatal error: Uncaught Exception in %s:%d
+Stack trace:
+#0 %s(%d): throwException()
+#1 %s(%d): {closure}()
+#2 %s(%d): loop()
+#3 {main}
+ thrown in %s on line %d
diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
index 4cd9087303..15bbfca1c5 100644
--- a/Zend/zend_generators.c
+++ b/Zend/zend_generators.c
@@ -857,6 +857,7 @@ try_again:
} else {
generator = zend_generator_get_current(orig_generator);
zend_generator_throw_exception(generator, NULL);
+ orig_generator->flags &= ~ZEND_GENERATOR_DO_INIT;
goto try_again;
}
}