[php-src] master: fibers: fix GH-23921 (Fibers start with error_reporting = 0 when the error_reporting INI directive is not set)
| From: | Gina Peter Banyard | Date: | Tue, 29 Sep 2026 14:29:38 +0000 |
| Subject: | [php-src] master: fibers: fix GH-23921 (Fibers start with error_reporting = 0 when the error_reporting INI directive is not set) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141679@lists.php.net to get a copy of this message | ||
Author: Gina Peter Banyard (Girgias)
Date: 2026-09-29T15:27:24+01:00
Commit: https://github.com/php/php-src/commit/3bb50c13a7a1819b2a1d6d160434a93f2c4f2faa
Raw diff: https://github.com/php/php-src/commit/3bb50c13a7a1819b2a1d6d160434a93f2c4f2faa.diff
fibers: fix GH-23921 (Fibers start with error_reporting = 0 when the error_reporting INI directive
is not set)
The way zend_fiber_execute() queries the error_reporting level is rather rather strange.
It cannot rely on the value of EG(error_reporting) as the @ silence operator may change it and this
it would leak into the body of a fiber.
However, we can simply query the underlying value of the INI setting to get the correct
error_reporting value as this is not modified by the @ operator.
Fixes an additional bug where the error_reporting value within a fiber was always E_ALL if the @
operator was used.
Closes GH-23930
Changed paths:
A Zend/tests/fibers/gh23921.phpt
A Zend/tests/fibers/silence-operator-outside-fiber-should-no-widen-error-reporting.phpt
M NEWS
M Zend/zend_fibers.c
Diff:
diff --git a/NEWS b/NEWS
index 73b488bd4ac6..9e4e2f40c45c 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,8 @@ PHP NEWS
state. (Ilia Alshanetsky)
. Fixed OSS-Fuzz #552682112 (assertion failure wrt
zp_arg_must_be_sent_by_ref()). (ndossche)
+ . Fixed GH-23921 (Fibers start with error_reporting = 0 when the
+ error_reporting INI directive is not set). (Girgias)
- FFI:
. Fixed crashes with FFI callbacks created from __call() trampolines
diff --git a/Zend/tests/fibers/gh23921.phpt b/Zend/tests/fibers/gh23921.phpt
new file mode 100644
index 000000000000..62c2a458fa62
--- /dev/null
+++ b/Zend/tests/fibers/gh23921.phpt
@@ -0,0 +1,17 @@
+--TEST--
+GH-23921 (Fibers start with error_reporting = 0 when the error_reporting INI directive is not set)
+--FILE--
+<?php
+echo error_reporting(), "\n";
+(new Fiber(function () {
+ echo error_reporting(), "\n";
+ echo $undefined;
+ echo "after\n";
+}))->start();
+?>
+--EXPECTF--
+30719
+30719
+
+Warning: Undefined variable $undefined in %s on line 5
+after
diff --git a/Zend/tests/fibers/silence-operator-outside-fiber-should-no-widen-error-reporting.phpt
b/Zend/tests/fibers/silence-operator-outside-fiber-should-no-widen-error-reporting.phpt
new file mode 100644
index 000000000000..9cb57c746936
--- /dev/null
+++ b/Zend/tests/fibers/silence-operator-outside-fiber-should-no-widen-error-reporting.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Silence operator must not change the error_reporting value within the fiber
+--FILE--
+<?php
+
+error_reporting(E_WARNING);
+
+@(new Fiber(function () {
+ var_dump(E_ALL);
+ var_dump(E_WARNING);
+ var_dump(error_reporting());
+}))->start();
+
+?>
+--EXPECT--
+int(30719)
+int(2)
+int(2)
diff --git a/Zend/zend_fibers.c b/Zend/zend_fibers.c
index c91436050856..f56d89a4177c 100644
--- a/Zend/zend_fibers.c
+++ b/Zend/zend_fibers.c
@@ -570,12 +570,9 @@ static ZEND_STACK_ALIGNED void zend_fiber_execute(zend_fiber_transfer
*transfer)
zend_fiber *fiber = EG(active_fiber);
- /* Determine the current error_reporting ini setting. */
+ /* We cannot rely on EG(error_reporting) as a silence operator @ may modify the executor global
error_reporting
+ * value without changing the underlying INI value */
zend_long error_reporting = zend_ini_long_literal("error_reporting");
- /* If error_reporting is 0 and not explicitly set to 0, zend_ini_str returns a null pointer. */
- if (!error_reporting && !zend_ini_str_literal("error_reporting")) {
- error_reporting = E_ALL;
- }
EG(vm_stack) = NULL;