fix(libkernel): answer pthread_getaffinity_np for the console's 8- and 16-byte sets #11431
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11431"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-26T13:11:32Z.
What
pthread_getaffinity_npaccepted exactly 32 bytes, FreeBSD'scpuset_t, and returnedERANGEfor every other size. The console does the opposite.PS5_PayloadSDK measured it in a title, the RetroArch title on firmware 12.09 (PROBE.md, "What a title reads about its CPUs"):
pthread_getaffinity_np"answers for set sizes of 8 and 16 bytes and returns ERANGE (34) for 32 bytes and more. FreeBSD'scpuset_tis 32 bytes, so code built on FreeBSD's headers always gets ERANGE." That fits FreeBSD's bounds check inkern_cpuset_getaffinitywith a 64-bit kernel set, which Prospero Win also measured forcpuset_getaffinity.The change:
ERANGE.pthread_setaffinity_npandcpuset_getaffinity/cpuset_setaffinitykeep FreeBSD's 32-byte limit. Neither is measured, so this PR leaves them as they are.guest_available_cpumasknow reads the affinity with 16 bytes and with 8 bytes. It checks that bytes 8 to 15 are zeroed and the bytes after the set untouched, and expectsERANGEfor 32, 33 and 64 bytes. It doesn't assert the throw for unmeasured sizes, which is an unimplemented path.Tested
Windows 11 Pro (26300), WinLibs GCC 15.2.0, Release, full build on
mainf759e165d9(head570ccce535):Thread.cppchange:guest_available_cpumaskfails.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.pyreports no line conflicts; #7135, which editscpuset_getaffinityin the same file, doesn't touchpthread_getaffinity_np. No title run: none in the catalog reaches this call.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T13:50:20Z.
Review: CHANGES_REQUESTED
The updated head now throws for 17–31 bytes, which addresses half of my earlier request. The 9–15 byte sizes remain successful, though the PR and debt entry both say those sizes are unmeasured. Please either provide console evidence for this interval or throw for it so the implementation stays within measured behavior.
The branch is based on
4b1a9a3b2f51, while currentmainis9656d366be90. The tree merges cleanly, and the relevantThread.cppandGuestAvailableCpumask.cppsources have not changed, but main has advanced and also edited the shared libkernel debt file. Please sync the branch, rerun conventions, and refresh the focused test report against the current base before final review. My localtools/check_conventions.py --base upstream/main --head upstream/pr-11431andgit diff --check upstream/main...upstream/pr-11431pass on the current fetched refs. I am requesting changes for the remaining unmeasured successful input range and the stale base/report.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T15:44:19Z.
Review: DISMISSED
I re-reviewed exact head
32d7260ad7db057bf060363dc763a4cdaa13e16e. The implementation now returns success only for the measured 8- and 16-byte masks, returnsERANGEfor sizes of 32 bytes or more, and throws for the unmeasured sizes below 32. The regression test and debt entry match that behavior. I withdraw my earlier request about the 9–15 byte range. The author reports all 406 registered libc/libkernel tests passing on Windows on this head.Current-main conventions and
git diff --checkpass, and the merge-tree preview is clean. The branch is based one38fcb00dc76, while currentmainisb0f1183ca12b; the only intervening change in this PR's paths is another edit todocs/dev/debt/libkernel.md. Please sync to current main and rerun conventions so the debt entry is integrated on the latest base. I did not independently run the Windows suite.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-26T16:07:11Z.
Review: APPROVED
Reviewed
32d7260ad7dbagainst2dbe9b99f577. No actionable findings.pthread_getaffinity_npnow succeeds only for measured 8- and 16-byte sets, returnsERANGEat 32 bytes or above, and throws for other smaller unmeasured sizes. The regression checks both supported sizes, rejected-size boundaries, null arguments, and output-buffer bounds.Validation: The Release target
guest_available_cpumask_testsbuilt successfully and focused CTest passed 1/1. An independent 0–64 size sweep confirmed only 8 and 16 succeed, withERANGEat and above 32 and buffer preservation on rejected inputs. Hosted conventions and labels passed; all hosted product build/test jobs were skipped. The patch also applies cleanly to localmain5bdda3661e2c; its intervening change is in the debt file, while the implementation and test are unchanged.The focused target was not rebuilt on that newer main, and no console/title test was run.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T09:02:56Z.
Review: CHANGES_REQUESTED
Re-check — changes requested\n\nThe new report resolves my previous request against base
4c7d275bef: guest_available_cpumask passes 3/3 and conventions pass; the single guest_freebsd_clocks failure is reported on main, and guest_filesystem passed 5/5 when isolated after one parallel failure.\n\nCurrent upstream main is nowaaccd0ba39, and this head is 44 commits behind it. Please update to current main and rerun guest_available_cpumask plus conventions on the exact resulting head. I did not independently run the Windows tests.