fix(libkernel): keep the pthread_mutexattr_setkind_np kind as firmware 13.42 does #10725
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10725"
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 dwk001 on 2026-10-24T19:50:54Z.
What
pthread_mutexattr_setkind_npthrew for a kind outside 1 to 4. It now behaves as the firmware 13.42libkernel.sprxmeasured in this thread: it keeps the low 16 bits of the kind as a signed value (0x8000 reads back as -32768, 0x12345 as 0x2345, 0x10001 as 1);pthread_mutexattr_gettypereturnsEINVALonly for a kind above 4, so 0 and negative kinds are returned with success; andpthread_mutex_initandscePthreadMutexInitreject a kind outside 1 to 4 withEINVALwithout touching the mutex. This differs from FreeBSD 11.4, which stores the fullint. The measurement was taken in an emulator, not on a console; noted indocs/dev/debt/libkernel.md.Tested
Linux, full build with
-DBUILD_TESTING=ON:ctest --test-dir build -R guest_pthread_mutexpasses (guest_pthread_mutexattr,guest_pthread_mutex_errors), covering each case above. Windows (GCC 15.2.0) reported passing by wachi35676.tools/check_conventions.py --base origin/mainpasses.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T20:03:14Z.
Review: APPROVED
Reviewed the invalid-kind paths and tests. The setter now stores arbitrary kinds; the getter rejects unsupported stored values without writing the output, and initialization rejects them before replacing the mutex. This matches the pinned FreeBSD 11.4 behavior cited in the PR. The author reports the focused Linux mutex tests pass, and hosted conventions/intake checks pass. The full hosted build was not available to this account (workflow dispatch returned HTTP 403). I found no blocking issue.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T20:20:15Z.
Review: COMMENTED
I found an interaction the current tests do not cover:
pthread_mutexattr_gettype_nid_postfixnow rejects a stored kind outside 1–4 usingstatic_cast<std::uint32_t>((*attr)->type) > 4. That correctly rejects the tested 5 and -1, but it treats stored kind 0 as valid and returns success. The issue is observable becauseCheckKindexplicitly sets kind 0 and currently expectsgettypeto return 0, while the stated FreeBSD behavior is that only recognized mutex types are valid at gettype/init time. Could you confirm the console/FreeBSD contract for kind 0 and, if it is invalid, reject values belowMutexType::ErrorChecktoo and assert thatpthread_mutexattr_gettypereturns EINVAL for 0? The code and tests otherwise cover storage and init rejection for the out-of-range values well.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T20:30:52Z.
Review: APPROVED
Re-reviewed exact head
0eb3a8c6ca14800c63e6581f8e02a145c0575606after the upstream merge. The author’s FreeBSD 11.4 distinction is reflected in both behavior and tests:gettypereturns stored kind 0 but rejects 5 and negative values; mutex initialization rejects every kind outside 1–4 without installing a mutex. I compiled the two changed mutex translation units andGuestPthreadMutexattr.cppwith GCC 12.2, and rangit diff --checkplustools/check_conventions.py --base upstream/main --head HEAD; all passed. The focused Linux CTest result is author-reported; this isolated checkout has no configured build tree, and hosted product tests are unavailable/skipped. I found no remaining blocking issue.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:00:46Z.
Review: APPROVED
Re-reviewed exact current head
e632137d7cd837ff203719fb7581669a5c405ed4after the emulator measurements were added. The new tests now match the reported firmware 13.42 behavior: the setter stores a signed 16-bit kind;gettypeaccepts negative values and rejects values above 4; initialization still rejects kinds outside 1–4 without installing the mutex. The changed translation units and test compile with GCC 12.2; exact-headgit diff --check upstream/main...HEADand conventions pass. Focused runtime CTest remains author-reported. The PR description correctly says not measured on a retail PS5.