ext/pcntl: fix an off by one bound and a parameter the parser made required - #23553
Open
lacatoire wants to merge 1 commit into
Open
ext/pcntl: fix an off by one bound and a parameter the parser made required#23553lacatoire wants to merge 1 commit into
lacatoire wants to merge 1 commit into
Conversation
devnexen
requested changes
Sep 4, 2026
…quired pcntl_setcpuaffinity() refuses a cpu id equal to the cpu count but named that count as the inclusive upper bound, printing a zend_long with the unsigned format on the way. pcntl_setqos_class() declares $qos_class optional while its parser demanded it, leaving the declared default unreachable.
lacatoire
force-pushed
the
fix/pcntl-qos-and-cpu-bound-upstream
branch
from
September 4, 2026 06:43
ad27950 to
6420da4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two unrelated slips in
ext/pcntl/pcntl.c, together because they touch the same file.pcntl_setcpuaffinity()rejectscpu >= maxcpusbut advertisesmaxcpusas the inclusive upper bound, so on a 16-CPU host id 16 is refused by a message saying "between 0 and 16". It now printsmaxcpus - 1. The same line printedmaxcpus, azend_long, withZEND_ULONG_FMT; corrected toZEND_LONG_FMT, sincesysconf()can return -1.pcntl_setqos_class()declares$qos_classoptional with a default ofPcntl\QosClass::Default, but its ZPP block was(1, 1)andqoswas left uninitialised, so calling it with no argument raised anArgumentCountErrorand the declared default was unreachable. It now parses(0, 1)withZ_PARAM_OPTIONALand initialisesqosbeforehand, asbcround()does for its optional enum parameter. This half is macOS-only and could not be exercised here.The new test reads the bound out of the message rather than hardcoding a cpu count, then checks that the advertised bound is accepted and the next id refused; it fails on the current code. Master only, as the exception message changes.