Repository navigation
feat(libSceDbgThreadSanitizer): declare the TSan annotation calls and report the sanitizer disabled - #4960
Merged
adriadam10 merged 1 commit intoOct 13, 2026
Conversation
… report the sanitizer disabled Black Myth: Wukong (PPSA23226) exits at start-up with STATUS_DLL_NOT_FOUND after "Failed to load module: libs\libSceDbgThreadSanitizer.prx". The executable does not need the library: its bundled sce_module/libSceJobManager_nosubmission.prx lists it in DT_NEEDED and imports __tsan_acquire and __tsan_release from it, plus sceKernelIsThreadSanitizerEnabled from libkernel. The relinker converts every module in sce_module and loads it at start-up (only --module-dir directories are deferred), and GuestModuleBuilder adds each module's host dependencies to the executable's DT_NEEDED, which the Windows start-up stub loads. libSceDbgThreadSanitizer now exports __tsan_acquire and __tsan_release with the void(void* addr) signatures of LLVM compiler-rt's tsan_interface.h (llvm-project 87f0227cb601, LLVM 20.1.8). Both throw: AnyPS5 runs no race detector, and the module calls them only after sceKernelIsThreadSanitizerEnabled reports the sanitizer enabled. libkernel's sceKernelIsThreadSanitizerEnabled returns 0, as sceKernelIsAddressSanitizerEnabled does; its int(void) signature is assumed and recorded in the libkernel debt file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Progress report (ea2bbef → 0f77f3e)📉 System libraries: 87.93% (-0.05%, +1 implemented, +2 declared functions) ✅ 1 implemented
⚪ 1 behaviourally empty (constant return or throw)
🆕 2 declared as stubs
|
9 tasks done
This was referenced Oct 13, 2026
Collaborator
|
Checked build and ctest (145 tests, |
11 tasks done
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
Black Myth: Wukong (PPSA23226) exits at start-up with
0xC0000135(STATUS_DLL_NOT_FOUND):Why the library is loaded at start-up. The executable does not reference it:
eboot.bin's DT_NEEDED has no libSceDbgThreadSanitizer and no libSceJobManager, andapp.registry.jsonhas no import from either. The title's ownsce_module/libSceJobManager_nosubmission.prxlistslibSceDbgThreadSanitizer.prxin its DT_NEEDED (the plainlibSceJobManager.prxdoes not), and its registry imports__tsan_acquire(XyX1104ACcU),__tsan_release(IkoI44e0OXc) andsceKernelIsThreadSanitizerEnabled(LzoM-wVLJDE, libkernel). In GuestModuleBuilder.cpp every ELF insce_moduleis converted and loaded at start-up (deferredapplies only to--module-dirdirectories), and each module's own DT_NEEDED (image.Dependencies) goes intohostLibraries, which becomes the executable's DT_NEEDED. The Windows start-up stub (WindowsEntryStubBuilder.cpp) then loads it. A missing library is skipped only when nothing imports from it (#3129), and this one has imports, so the load fails.Change.
core/libs/prx/libSceDbgThreadSanitizer. It is anExport.cpp-only directory, which theprx/*glob incore/libs/CMakeLists.txtregisters andnid_patcherpatches, as for libSceXml. It declares__tsan_acquireand__tsan_releasewith thevoid(void* addr)signatures from LLVM compiler-rttsan_interface.hat llvm-project 87f0227 (LLVM 20.1.8), lines 24-25. The names hash to the imported NIDs. Both throw throughNotImplemented_nid_no_patch, because AnyPS5 runs no race detector.sceKernelIsThreadSanitizerEnabledin libkernel (Sanitizer.cpp) returns 0. A converted title never runs under the sanitizer. It sits next tosceKernelIsAddressSanitizerEnabled, which also returns 0.sceKernelIsThreadSanitizerEnabled.int(void)is assumed from the address-sanitizer counterpart and from how the module uses it, and is recorded under Unknown function info indocs/dev/debt/libkernel.md. The constant result is also listed there under Silent stubs, because the conventions check requires that for ansce*export whose body only returns a constant (as forsceKernelGetMainSocId). The TSan signature assumption is in the newdocs/dev/debt/libSceDbgThreadSanitizer.md.Behaviour of the module (from reading it locally; no code is reproduced here). One initialisation routine calls
sceKernelIsThreadSanitizerEnabledwithout setting up arguments. If the 32-bit result is nonzero, it sets a module-wide flag. That routine is the only writer of the flag. All 60 call sites of__tsan_acquire/__tsan_releasecheck the flag first and skip the call when it is clear. With the kernel reporting 0, the throwing stubs are never reached.Tested
Windows Server 2025, MinGW-w64 GCC 15.2.0,
build-dev(Release).guest_thread_sanitizertest: the guest callssceKernelIsThreadSanitizerEnabledand requires 0. It passes with the change. WithSanitizer.cppreverted and libkernel rebuilt, it fails with0xC0000139(entry point not found); a clean build fails to link. No export-only test was added for libSceDbgThreadSanitizer (CONTRIBUTING).patched_librariesandguest_software_versionpass. Exports were checked on the patchedlibSceDbgThreadSanitizer.prx(IkoI44e0OXc,XyX1104ACcU) and onlibkernel.prx(LzoM-wVLJDE).tools/import_audit.pyon the 41 PPSA23226 registries, with the title'ssce_moduleandprxas modules:absent 3 imports(the two TSan NIDs andLzoM-wVLJDE)libs:absent 0 imports,implemented 1088,stub 49(the two new throwing stubs count as stubs)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