fix(libkernel): handle available sem_timedwait counts first #3691
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3691"
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 MarcZX10 on 2026-10-11T15:23:45Z.
What
sem_timedwaitnow consumes an available semaphore count before validatingabstime, as permitted by POSIX. A null timeout waits indefinitely when the semaphore is empty; malformed and expired timeouts still returnEINVALandETIMEDOUTwhen the call would block.This carries the available-count-before-timeout behavior from Miles Coviello's ready fix branch, with co-author credit in the commit. The implementation follows FreeBSD's
_sem_clockwait_npbehavior; the added regression cases also cover a blocked null-timeout waiter waking aftersem_post.Fixes #3119.
Tested
Linux, GCC 12.2, Release:
guest_posix_sem_postpasses. I also rebuilt the test against unmodifiedmain; it fails on the new available-count/null-timeout case, then passes with this change.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-11T15:24:44Z.
Thanks for picking up #3119, @MarcZX100. It's the change from my branch linked there (
fix/sem-timedwait-timeout-check,e7d71abf, verified on Windows by @hikazey in #3119): take an available count first, and a null timeout waits with no limit. Yours is closer to libthr, though, since it skips the cancellation check on that fast path. Would you mind addingCo-authored-by: milescoviello <[email protected]>like on #3436? Thanks either way.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T15:25:36Z.
Thanks for pointing out the source branch. I added the commit trailer
Co-authored-by: milescoviello <[email protected]>, updated the PR description to link your ready branch, and force-pushed the attribution-only rewrite. The current head is9b686ec1b2a372d8aa7dbcb7f43e473a91805ae7.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T22:02:48Z.
Checked:
guest_posix_sem_postpasses with the change and fails without it (new available-count/null-timeout cases); ctest for core/libs and libkernel 112/112; blocked invalid/expired timeouts still return EINVAL/ETIMEDOUT and keep the count. Matches FreeBSD_sem_clockwait_npand the Windows run reported by @hikazey in #3119. Merging.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T22:26:16Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/TechnicalDebt.mdL369