[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
| From: | David Carlier | Date: | Sat, 26 Sep 2026 17:26:55 +0000 |
| Subject: | [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141581@lists.php.net to get a copy of this message | ||
Author: David Carlier (devnexen)
Date: 2026-09-26T18:26:08+01:00
Commit: https://github.com/php/php-src/commit/40364dddee4ce46d1f3a49facce2b8426c5543ba
Raw diff: https://github.com/php/php-src/commit/40364dddee4ce46d1f3a49facce2b8426c5543ba.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
ext/pcntl: fix an off by one bound and a parameter the parser made required
# Conflicts:
# ext/pcntl/pcntl.c
Changed paths:
A ext/pcntl/tests/pcntl_cpuaffinity_bound.phpt
M ext/pcntl/pcntl.c
M ext/pcntl/tests/pcntl_qosclass.phpt
Diff:
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 38e6c4ae2bc3..0646e7ba043f 100644
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -1818,7 +1818,7 @@ PHP_FUNCTION(pcntl_setcpuaffinity)
}
if (cpu < 0 || cpu >= maxcpus) {
- zend_argument_value_error(2, "cpu id must be between 0 and " ZEND_ULONG_FMT "
(" ZEND_LONG_FMT ")", maxcpus, cpu);
+ zend_argument_value_error(2, "cpu id must be between 0 and " ZEND_LONG_FMT "
(" ZEND_LONG_FMT ")", maxcpus - 1, cpu);
PCNTL_CPU_DESTROY(mask);
RETURN_THROWS();
}
@@ -1925,9 +1925,10 @@ PHP_FUNCTION(pcntl_getqos_class)
PHP_FUNCTION(pcntl_setqos_class)
{
- zend_enum_Pcntl_QosClass qos;
+ zend_enum_Pcntl_QosClass qos = ZEND_ENUM_Pcntl_QosClass_Default;
- ZEND_PARSE_PARAMETERS_START(1, 1)
+ ZEND_PARSE_PARAMETERS_START(0, 1)
+ Z_PARAM_OPTIONAL
Z_PARAM_ENUM(qos, QosClass_ce)
ZEND_PARSE_PARAMETERS_END();
diff --git a/ext/pcntl/tests/pcntl_cpuaffinity_bound.phpt
b/ext/pcntl/tests/pcntl_cpuaffinity_bound.phpt
new file mode 100644
index 000000000000..6b415a52c242
--- /dev/null
+++ b/ext/pcntl/tests/pcntl_cpuaffinity_bound.phpt
@@ -0,0 +1,52 @@
+--TEST--
+pcntl_setcpuaffinity(): the upper bound the error advertises is itself a valid cpu id
+--EXTENSIONS--
+pcntl
+--SKIPIF--
+<?php
+if (PHP_OS_FAMILY === 'Solaris') {
+ die("skip broken pset_create()");
+}
+if (!function_exists("pcntl_setcpuaffinity")) die("skip pcntl_setcpuaffinity is not
available");
+?>
+--FILE--
+<?php
+$pid = getmypid();
+$prefix = 'pcntl_setcpuaffinity(): Argument #2 ($cpu_ids) cpu id must be between 0 and ';
+
+/* read the advertised bound out of the message itself */
+try {
+ pcntl_setcpuaffinity($pid, [PHP_INT_MAX]);
+ exit("PHP_INT_MAX was accepted as a cpu id" . PHP_EOL);
+} catch (Throwable $e) {
+ echo $e::class, "\n";
+ if (!preg_match('/must be between 0 and (\d+) \(/', $e->getMessage(), $m)) {
+ exit("unexpected message: " . $e->getMessage() . PHP_EOL);
+ }
+}
+$bound = (int) $m[1];
+
+/* Every id is range checked before any syscall runs, so pairing the advertised
+ bound with an out of range id shows which of the two the check rejects,
+ without ever changing the process affinity. */
+try {
+ pcntl_setcpuaffinity($pid, [$bound, PHP_INT_MAX]);
+} catch (Throwable $e) {
+ echo $e::class, "\n";
+ var_dump($e->getMessage() === $prefix . $bound . ' (' . PHP_INT_MAX .
')');
+}
+
+/* and the first id past the bound is rejected, naming itself */
+try {
+ pcntl_setcpuaffinity($pid, [$bound + 1]);
+} catch (Throwable $e) {
+ echo $e::class, "\n";
+ var_dump($e->getMessage() === $prefix . $bound . ' (' . ($bound + 1) .
')');
+}
+?>
+--EXPECT--
+ValueError
+ValueError
+bool(true)
+ValueError
+bool(true)
diff --git a/ext/pcntl/tests/pcntl_qosclass.phpt b/ext/pcntl/tests/pcntl_qosclass.phpt
index f8ca1a706bd2..947afdb4836b 100644
--- a/ext/pcntl/tests/pcntl_qosclass.phpt
+++ b/ext/pcntl/tests/pcntl_qosclass.phpt
@@ -13,7 +13,12 @@ pcntl_setqos_class(Pcntl\QosClass::Default);
var_dump(Pcntl\QosClass::Default === pcntl_getqos_class());
pcntl_setqos_class(Pcntl\QosClass::Background);
var_dump(Pcntl\QosClass::Background == pcntl_getqos_class());
+
+/* the parameter is optional, and omitting it applies the declared default */
+pcntl_setqos_class();
+var_dump(Pcntl\QosClass::Default === pcntl_getqos_class());
?>
--EXPECT--
bool(true)
bool(true)
+bool(true)