Skip to content

test(libSceLibcInternal): pin _Mtx_current_owns across slot states - #22334

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
olegon85:test/libscelibcinternal-mtx-current-owns-states
Nov 17, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
olegon85:test/libscelibcinternal-mtx-current-owns-states

Conversation

@olegon85

Copy link
Copy Markdown
Contributor

What

docs/dev/debt/changes/docs-libc-mtx-current-owns-console-1160.md records that _Mtx_current_owns "returns 1 and ignores its argument" and that "A payload process on PS5 firmware 11.60 measured 1 as well in six calls: before locking, locked by the caller, after unlocking, held by another thread, for a zeroed unused slot and after _Mtx_destroy". The existing test pinned only the null-slot call added with the forward table; the new function pins the other five states of that matrix on one mutex — unlocked, locked by the caller, unlocked again, locked while observed from a second thread, and destroyed — plus the zeroed unused slot. No console measurement is claimed beyond what the debt file records.

Tested

  • Debian 12 x86-64 (WSL), head 83bcb46b3e93d8d33d5782e3b94cec89c87d9179 on base cb28e72762: cmake --build build --target guest_libc_threads_tests, ctest -R '^guest_libc_threads$' — Passed, two consecutive runs, plus three direct runs of the binary (exit 0 each).
  • Windows cross-compile syntax check of the changed test (x86_64-w64-mingw32-g++-posix -fsyntax-only, GCC 12 posix): clean.
  • python tools/check_conventions.py --base origin/main: passed. git diff --check: clean. python tools/pr_overlap.py --branch test/libscelibcinternal-mtx-current-owns-states: the only shared file is feat(libc): add the std::__sce_v2 thread start, timed wait, clock and processor count calls #9447, and the overlap is positional — that PR appends __sce_v2 declarations after line 54 and new functions after ForwardedCalls, while this adds one function directly before int main() and one call line after DefaultNameOverrideMutex(); neither touches _Mtx_current_owns behavior.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 83bcb46b3e:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_libc_threads_tests built cleanly.
  • CTest (guest_libc_threads):
    1/1 Test #1197: guest_libc_threads ...............   Passed    0.29 sec
    100% tests passed, 0 tests failed out of 1
    
  • Code reading:
    • Verified that CurrentOwnsAnswersForEverySlotState() in core/libs/tests/GuestLibcThreads.cpp exercises _Mtx_current_owns across all intended states: unlocked, locked by caller, unlocked again, locked by another thread, null/unused slot, and post-destruction.
    • Confirmed thread synchronization and lifetime safety: the spawned std::thread in CurrentOwnsAnswersForEverySlotState observes the locked mutex and is joined before unlocking and destruction.
    • Verified AGENTS.md compliance: no forbidden comments, no new files outside allowed rules, clean convention gate, and proper Conventional Commits format.
    • Verified cross-platform portability and clean destruction lifecycle with _Mtx_destroy_nid_postfix(&mutex).

Looks Good To Me

@oneandonlydean
oneandonlydean merged commit 1438fc1 into boykopovar:main Nov 17, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants