feat(libSceDbgThreadSanitizer): add no-op implementations for __tsan_acquire and __tsan_release #6830

Merged
ErenYeager1836 merged 3 commits from upstream-pr/6830 into main 2026-11-01 00:18:36 +00:00
ErenYeager1836 commented 2026-10-16 13:35:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-16T13:35:17Z.


What

Provide safe no-op implementations for __tsan_acquire and __tsan_release in libSceDbgThreadSanitizer.
Currently, these functions call NotImplemented_nid_no_patch(__func__), which causes fatal aborts if invoked by titles or debug libraries (such as PPSA23226's bundled libSceJobManager_nosubmission.prx). Because AnyPS5 does not run a race detector and sceKernelIsThreadSanitizerEnabled returns 0, these functions safely behave as no-ops.

  • Updated __tsan_acquire and __tsan_release in core/libs/prx/libSceDbgThreadSanitizer/Export.cpp to ignore their address arguments.
  • Documented both functions under ### Silent stubs in docs/dev/debt/libSceDbgThreadSanitizer.md and updated the cross-reference in docs/dev/debt/libkernel.md.
  • Added assertions exercising both functions with null and valid pointers in GuestThreadSanitizer.cpp, and linked libSceDbgThreadSanitizer in guest_thread_sanitizer_tests.

Tested

Windows 11, unit test suite (guest_thread_sanitizer_tests). Verified __tsan_acquire and __tsan_release execute cleanly without throwing when called with nullptr and a local object address, and verified sceKernelIsThreadSanitizerEnabled returns 0.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4889154908 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6830). Originally posted by [ErenYeager1836](https://github.com/ErenYeager1836) on 2026-10-16T13:35:17Z. --- ### What Provide safe no-op implementations for `__tsan_acquire` and `__tsan_release` in `libSceDbgThreadSanitizer`. Currently, these functions call `NotImplemented_nid_no_patch(__func__)`, which causes fatal aborts if invoked by titles or debug libraries (such as PPSA23226's bundled `libSceJobManager_nosubmission.prx`). Because AnyPS5 does not run a race detector and `sceKernelIsThreadSanitizerEnabled` returns 0, these functions safely behave as no-ops. - Updated `__tsan_acquire` and `__tsan_release` in `core/libs/prx/libSceDbgThreadSanitizer/Export.cpp` to ignore their address arguments. - Documented both functions under `### Silent stubs` in `docs/dev/debt/libSceDbgThreadSanitizer.md` and updated the cross-reference in `docs/dev/debt/libkernel.md`. - Added assertions exercising both functions with null and valid pointers in `GuestThreadSanitizer.cpp`, and linked `libSceDbgThreadSanitizer` in `guest_thread_sanitizer_tests`. ### Tested Windows 11, unit test suite (`guest_thread_sanitizer_tests`). Verified `__tsan_acquire` and `__tsan_release` execute cleanly without throwing when called with `nullptr` and a local object address, and verified `sceKernelIsThreadSanitizerEnabled` returns 0. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-16 13:41:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T13:41:26Z.


One Windows test setup issue: the ENVIRONMENT_MODIFICATION value currently escapes the semicolon between two PATH=path_list_prepend:... entries (\;). CMake preserves that as a literal escaped semicolon in one list item (cmake -P confirms list length 1); CTest expects two list entries, one for libkernel and one for libSceDbgThreadSanitizer. Please remove the escape so the property receives both modifications. Otherwise the Windows test may not find the newly linked sanitizer DLL at runtime.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6216789438 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6830#issuecomment-6216789438). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T13:41:26Z. --- One Windows test setup issue: the `ENVIRONMENT_MODIFICATION` value currently escapes the semicolon between two `PATH=path_list_prepend:...` entries (`\;`). CMake preserves that as a literal escaped semicolon in one list item (`cmake -P` confirms list length 1); CTest expects two list entries, one for `libkernel` and one for `libSceDbgThreadSanitizer`. Please remove the escape so the property receives both modifications. Otherwise the Windows test may not find the newly linked sanitizer DLL at runtime.
ErenYeager1836 commented 2026-10-16 13:54:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-16T13:54:16Z.


Good catch, thank you! Updated the test property to unescape the semicolon so CTest receives both directory entries.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6217035466 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6830#issuecomment-6217035466). Originally posted by [ErenYeager1836](https://github.com/ErenYeager1836) on 2026-10-16T13:54:16Z. --- Good catch, thank you! Updated the test property to unescape the semicolon so CTest receives both directory entries.
MarcZX10 commented 2026-10-16 13:54:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T13:54:48Z.


Thanks, I verified the updated CMake property now separates the two PATH modifications. That resolves my Windows test setup concern.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6217045834 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6830#issuecomment-6217045834). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T13:54:48Z. --- Thanks, I verified the updated CMake property now separates the two PATH modifications. That resolves my Windows test setup concern.
jotitadev commented 2026-10-16 16:50:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T16:50:47Z.

Review: COMMENTED


First Linux run of this PR.

Machine: Intel i7-8700, Ubuntu 26.04, GCC 15.2, CMake 4.2.3, Release. Head acac9dfe1 merged on main 143f13055.

  • Build clean, no new warnings. guest_thread_sanitizer passes.
  • Non-GPU suite (-E "^agc|gpu|vulkan|video_out"): 648/650, the same as main here; only file_writer_binary and file_writer_text fail, on both.
  • Test-only control: the new GuestThreadSanitizer.cpp and the libkernel/CMakeLists.txt link change on main, with Export.cpp from main, abort with __tsan_acquire not implemented. So the test covers the change on Linux too.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5550936194 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6830#pullrequestreview-5550936194). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-16T16:50:47Z. **Review:** COMMENTED --- First Linux run of this PR. Machine: Intel i7-8700, Ubuntu 26.04, GCC 15.2, CMake 4.2.3, Release. Head `acac9dfe1` merged on `main` `143f13055`. - Build clean, no new warnings. `guest_thread_sanitizer` passes. - Non-GPU suite (`-E "^agc|gpu|vulkan|video_out"`): 648/650, the same as `main` here; only `file_writer_binary` and `file_writer_text` fail, on both. - Test-only control: the new `GuestThreadSanitizer.cpp` and the `libkernel/CMakeLists.txt` link change on `main`, with `Export.cpp` from `main`, abort with `__tsan_acquire not implemented`. So the test covers the change on Linux too. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!6830
No description provided.