Repository navigation
fix(libkernel): time out timed locks of a lock the caller already holds - #9165
Open
MaxLikesCode wants to merge 1 commit into
Open
MaxLikesCode wants to merge 1 commit into
MaxLikesCode wants to merge 1 commit into
Conversation
scePthreadMutexTimedlock on a mutex the caller holds, and scePthreadRwlockTimedrdlock and scePthreadRwlockTimedwrlock on a rwlock it holds for writing, returned EDEADLK at once. The console returns ETIMEDOUT, as the prosper console oracle measured. They now sleep until the timeout and return ETIMEDOUT, as FreeBSD libthr does. The POSIX timed locks call these and change with them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
Contributor
|
Linux data point for
|
Contributor
Author
|
Thanks @xXPBSXx for the Linux run and the check with AI-assisted: yes (Claude Code) |
12 tasks done
12 tasks done
This branch has not been deployed
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
A timed lock of a lock the caller already holds now waits out its timeout and returns
ETIMEDOUT, instead of returningEDEADLKat once:scePthreadMutexTimedlockon a non-recursive mutex the caller holds.scePthreadRwlockTimedrdlockandscePthreadRwlockTimedwrlockon a rwlock the caller holds for writing.The untimed
scePthreadMutexLock,scePthreadRwlockRdlockandscePthreadRwlockWrlockstill returnEDEADLK.Where the behaviour comes from:
ETIMEDOUT(0x8002003c) after a 1000 us timeout for a default mutex and for both rwlock calls (mutex, rwlock). Only the result was measured, not whether the console waited.mutex_self_locksleeps until the deadline and returnsETIMEDOUTfor error-checking, adaptive and normal mutexes (thr_mutex.c L878-L928). The rwlock locks have no deadlock check and wait in the kernel (thr_rwlock.c L159-L329). So the calls here sleep until the timeout too.The POSIX
pthread_mutex_timedlock,pthread_mutex_reltimedlock_np,pthread_rwlock_timedrdlockandpthread_rwlock_timedwrlockcall these functions and change with them. Two tests expectedEDEADLKfrom them, which no measurement or FreeBSD source supports:guest_pthread_rwlock, from the POSIX timed rwlock locks. It now expectsETIMEDOUT, and its 5 s deadline is now 20 ms, since the call really waits.guest_pthread_mutex_errors, frompthread_mutex_reltimedlock_npon a mutex the caller holds (added in feat(libkernel): add mutex ownership, relative lock and spin/yield accessors #8400, which describes that function asscePthreadMutexTimedlockwith POSIX error numbers). It now expectsETIMEDOUTafter its 1000 us timeout.The adaptive and normal mutex types and the POSIX names were not measured;
docs/dev/debt/libkernel.mdsays so.Tested
BUILD_TESTING=ON, onmain1b5d702.guest_kernel_errorspasses with new cases: a timed lock of an error-checking, adaptive, default and normal mutex the caller holds, and both timed rwlock locks while the caller holds the write lock. Each returnsETIMEDOUTafter at least 15 ms of a 20 ms timeout, and the lock is taken normally once released. It fails without the changes toMutex.cppandRwlock.cpp.guest_kernel_errors,guest_pthread_rwlock,guest_pthread_mutex_errorsandguest_pthread_timed_lockspass 3 of 3.python tools/select_tests.py ctest build --output-on-failure --timeout 120 --parallel 4: onmain1b5d702 all 739 selected tests outsideagc_pass. A run of all 1517 selected tests one rebase earlier, onmain47fa6ee, passed 1514; the 3 failures wereagc_driver_sample_order,agc_driver_sample_order_grid_referenceandagc_driver_sample_order_recipe_depth_locationsfrom fix(agc): keep the guest's sample order where pixel (0,0)'s locations stand in for a 2x2 grid #6683, which fail with the same messages on thatmainon this RTX 4090.agc_driver_image_array_window_past_layer_limitis not built: it does not compile with MinGW onmain(test(agc): align the array window test's texels at run time #8310).python tools/check_conventions.py --base origin/mainpasses.python tools/pr_overlap.py --branch fix/pthread-timed-self-lockreports no open PR changing the same lines or exports.3959305a27:guest_pthread_mutex_errors,guest_pthread_rwlockandguest_kernel_errorspass 3 of 3, and all three fail withMutex.cppandRwlock.cpprestored to the merge base.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