Repository navigation
test(libkernel_sys): expect the macOS kernel's EINVAL for wait4 with pid INT_MIN - #19924
Merged
Merged
Conversation
PrivacyOnion
approved these changes
Nov 14, 2026
PrivacyOnion
left a comment
Contributor
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 514966ffda:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_kernel_sys_wait_testsbuilt cleanly. - CTest (
guest_kernel_sys_wait_wait3,guest_kernel_sys_wait_wait3_patched,guest_kernel_sys_wait_wait4,guest_kernel_sys_wait_wait4_patched,guest_kernel_sys_wait__wait4,guest_kernel_sys_wait__wait4_patched):1/6 Test #832: guest_kernel_sys_wait_wait3 ............ Passed 0.05 sec 2/6 Test #833: guest_kernel_sys_wait_wait3_patched .... Passed 0.05 sec 3/6 Test #834: guest_kernel_sys_wait_wait4 ............ Passed 0.04 sec 4/6 Test #835: guest_kernel_sys_wait_wait4_patched .... Passed 0.04 sec 5/6 Test #836: guest_kernel_sys_wait__wait4 ........... Passed 0.04 sec 6/6 Test #837: guest_kernel_sys_wait__wait4_patched ... Passed 0.05 sec 100% tests passed, 0 tests failed out of 6 - Code reading:
- Verified in core/libs/tests/GuestKernelSysWait.cpp that the macOS expectation of EINVAL (22) under defined(APPLE) accurately matches the Darwin/XNU kernel sys_wait4 implementation, which explicitly rejects pid == INT_MIN with EINVAL to prevent signed negation overflow in -pid.
- Verified in core/libs/tests/GuestKernelSysWait.cpp that the condition (options & ~0x8000003fu) == 0 && test != "wait3" && pid == std::numeric_limits::min() properly excludes wait3 (which does not receive a pid argument and expects ECHILD 10) and preserves EINVAL (22) when invalid option bits are passed.
- Verified in core/libs/tests/GuestKernelSysWait.cpp that expectations on Linux (ESRCH 3) and Windows (ECHILD 10) remain completely unchanged across all iterations of pid and options.
- Verified that no comments were added to core/libs/tests/GuestKernelSysWait.cpp, adhering strictly to the AGENTS.md rule prohibiting code comments outside #endif and namespace closures.
- Verified type safety and signedness in comparisons between pid and std::numeric_limits::min() as well as unsigned option bitmasking, ensuring clean compilation across GCC, Clang, and MSVC without warnings.
- Note: the AI-assisted checkbox can stay.
Looks Good To Me
Contributor
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
Open
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.
What
guest_kernel_sys_waitalready expects the host kernel's error forwait4/_wait4withpid == INT_MINon Linux (ESRCH, 3), sinceWaitProcess_nid_no_patchpasses the host::wait4errno through and the FreeBSD answer (ECHILD, 10) comes from FreeBSD's own process-group lookup. macOS was not listed: its kernel rejectspid == INT_MINwithEINVAL(22), so the fourwait4variants fail there on the first valid option:This adds the macOS expectation beside the Linux one, under the same condition. Only the test changes; Linux, Windows and the other
pid/option combinations are unchanged.Tested
macOS 26.7.3, Apple M4, Apple clang 21.0.0, full build (
-DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DCMAKE_OSX_ARCHITECTURES=x86_64, tests under Rosetta) onmainwith #17425, #11049, #11437, #19903 and #19920 merged locally:guest_kernel_sys_wait_wait4,_wait4_patched,__wait4and__wait4_patchedfail with the output above.guest_kernel_sys_wait_*tests pass, which also runs every otherpid/option pair the first failure used to stop.python3 tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)