Commit Graph
9 Commits
Author SHA1 Message Date
Dean 49025cb436 Merge pull request #12463 from Oscar45397/test/libkernel-posix-sem-deadline
test(libkernel): cover a future sem_timedwait deadline
2026-10-29 23:49:44 +13:00
Oscar45397andClaude Opus 5.5 3f105bcee4 test(libkernel): drop the use-after-sem_destroy checks
POSIX leaves using a semaphore after sem_destroy undefined, and EINVAL
there rested only on FreeBSD's libc source, not on a console result.
Keep the future-deadline checks, which POSIX defines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 22:04:41 +01:00
Oscar45397andClaude Opus 5.5 c18bebb6b7 test(libkernel): cover a future sem_timedwait deadline and use after sem_destroy
GuestPosixSem timed out sem_timedwait only on an expired deadline and
never used a semaphore after sem_destroy. CheckFutureDeadline requires a
realtime deadline 50 ms ahead to fail with ETIMEDOUT after at least
40 ms without changing the count, and a post before a 5 s deadline to
release the waiter with 0. CheckDestroyed requires sem_wait, sem_trywait,
sem_timedwait, sem_post, sem_getvalue and a second sem_destroy on a
destroyed semaphore to fail with EINVAL, as FreeBSD's libc does once
sem_destroy has cleared the semaphore.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 22:04:41 +01:00
kenny soloandClaude Opus 5.5 20c9a93999 feat(libkernel): implement sem_setname
Keep a copy of the name with the semaphore and move the export from the libkernel_sys stub into libkernel next to the other sem_* exports.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-28 14:51:17 +01:00
Dean de2e6728f3 Merge pull request #8616 from Lindamea1/fix/libkernel-posix-sem-post-notify-under-lock
fix(libkernel): notify a POSIX semaphore waiter before sem_post releases its lock
2026-10-26 11:02:29 +13:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Lindamea1andClaude Opus 5.5 47b5a750ad fix(libkernel): notify a POSIX semaphore waiter before sem_post releases its lock
sem_post raised the count under the semaphore's lock, released the
lock, and only then called NotifyOne on the heap PosixSemaphore. A
thread that took the count in that gap could call sem_destroy, which
deletes the object, and the poster then ran NotifyOne on freed memory.
FreeBSD 11.4's sem_post touches only the caller's sem_t after it
publishes the token, and its sem_destroy only clears _magic, so a
thread may destroy the semaphore as soon as its wait returns.

Call NotifyOne before the lock is released. A thread takes the count
only under that lock, so the unlock is the poster's last access.
guest_posix_sem_post now runs 20000 rounds that post to a semaphore
the main thread destroys once sem_trywait gets the count; with the old
order the poster crashes in NotifyOne.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-20 19:30:14 +01:00
MarcZX100andmilescoviello 8935160160 fix(libkernel): handle available sem_timedwait counts first
Co-authored-by: milescoviello <[email protected]>
2026-10-11 23:54:18 +02:00
RomainROCH eae05782af fix(libkernel): enforce POSIX semaphore count limits 2026-10-03 04:03:25 +02:00