fix(libSceSysmodule): return unloaded for measured internal id #19323

Merged
Cr0me1ve merged 1 commit from upstream-pr/19323 into main 2026-11-13 17:48:30 +00:00
Cr0me1ve commented 2026-11-13 03:33:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Cr0me1ve on 2026-11-13T03:33:04Z.


What

Implement the measured unloaded result for sceSysmoduleIsLoadedInternal(0x800000c4): return SCE_SYSMODULE_ERROR_UNLOADED when this internal module ID is absent from the module table.

Tested

Host-side build on Ubuntu 24.04 x86-64 under WSL2:
cmake --build build --target guest_sysmodule_tests guest_sysmodule_invalid_ids_tests --parallel 4

Passed 3/3 host tests with:
ctest --test-dir build --output-on-failure -R "^(guest_sysmodule|guest_sysmodule_maps_scan|guest_sysmodule-invalid-ids)$"

No PS5 or title was available; this was not run on console hardware.

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:5289476046 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19323). Originally posted by [Cr0me1ve](https://github.com/Cr0me1ve) on 2026-11-13T03:33:04Z. --- ### What Implement the measured unloaded result for `sceSysmoduleIsLoadedInternal(0x800000c4)`: return `SCE_SYSMODULE_ERROR_UNLOADED` when this internal module ID is absent from the module table. ### Tested Host-side build on Ubuntu 24.04 x86-64 under WSL2: `cmake --build build --target guest_sysmodule_tests guest_sysmodule_invalid_ids_tests --parallel 4` Passed 3/3 host tests with: `ctest --test-dir build --output-on-failure -R "^(guest_sysmodule|guest_sysmodule_maps_scan|guest_sysmodule-invalid-ids)$"` No PS5 or title was available; this was not run on console hardware. ### 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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
PrivacyOnion commented 2026-11-13 04:53:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-13T04:53:06Z.

Review: APPROVED


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

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_sysmodule_tests built cleanly.
  • CTest (guest_sysmodule, guest_sysmodule_maps_scan):
    1/2 Test #4206: guest_sysmodule_maps_scan ........   Passed    0.01 sec
    2/2 Test #4205: guest_sysmodule ..................   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 2
    
  • Negative control: with core/libs/prx/libSceSysmodule/Export.cpp reverted to main and the new tests kept, the suite fails:
    1/2 Test #4206: guest_sysmodule_maps_scan ........Subprocess aborted***Exception:   0.17 sec
    2/2 Test #4205: guest_sysmodule ..................Subprocess aborted***Exception:   0.19 sec
    0% tests passed, 2 tests failed out of 2
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified in core/libs/prx/libSceSysmodule/Export.cpp:344-349 that sceSysmoduleIsLoadedInternal checks (id & 0x7fffffffu) == 0 first, and upon findModuleName(id) returning nullptr correctly intercepts kMeasuredInternalUnloadedModuleId (0x800000c4u) to return SCE_SYSMODULE_ERROR_UNLOADED (0x805A1001) before evaluating isMeasuredRejectedInternalId and 0x00ffffffu.
    • Verified thread safety in core/libs/prx/libSceSysmodule/Export.cpp:344-356: unmapped ID resolution reads immutable kModuleTable without data races, returns without mutating state, and mapped IDs continue to synchronize on gMutex when inspecting gLoadCount.
    • Verified cross-platform LP64 and LLP64 type safety in core/libs/prx/libSceSysmodule/Export.cpp:33 and core/libs/tests/GuestSysmodule.cpp:63: kMeasuredInternalUnloadedModuleId is explicitly typed as constexpr std::uint32_t with literal 0x800000c4u, matching the uint32_t parameter type without sign extension or truncation.
    • Verified test coverage in core/libs/tests/GuestSysmodule.cpp:321: Require(sceSysmoduleIsLoadedInternal(kMeasuredInternalUnloadedModuleId) == kModuleUnloaded) directly exercises the new unloaded branch without altering global state or impacting subsequent module lifecycle tests.
    • Verified compliance with AGENTS.md: confirmed no comments were added in code in Export.cpp or GuestSysmodule.cpp, no unauthorized files were created, and docs/dev/debt/libSceSysmodule.md was updated to reflect the remaining throwing internal variants.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5886334947 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/19323#pullrequestreview-5886334947). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-13T04:53:06Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `faa3e2df7b`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_sysmodule_tests` built cleanly. - **CTest** (`guest_sysmodule`, `guest_sysmodule_maps_scan`): ``` 1/2 Test #4206: guest_sysmodule_maps_scan ........ Passed 0.01 sec 2/2 Test #4205: guest_sysmodule .................. Passed 0.01 sec 100% tests passed, 0 tests failed out of 2 ``` - **Negative control**: with `core/libs/prx/libSceSysmodule/Export.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 1/2 Test #4206: guest_sysmodule_maps_scan ........Subprocess aborted***Exception: 0.17 sec 2/2 Test #4205: guest_sysmodule ..................Subprocess aborted***Exception: 0.19 sec 0% tests passed, 2 tests failed out of 2 ``` Restoring the change makes it pass again. - **Code reading**: - Verified in core/libs/prx/libSceSysmodule/Export.cpp:344-349 that sceSysmoduleIsLoadedInternal checks (id & 0x7fffffffu) == 0 first, and upon findModuleName(id) returning nullptr correctly intercepts kMeasuredInternalUnloadedModuleId (0x800000c4u) to return SCE_SYSMODULE_ERROR_UNLOADED (0x805A1001) before evaluating isMeasuredRejectedInternalId and 0x00ffffffu. - Verified thread safety in core/libs/prx/libSceSysmodule/Export.cpp:344-356: unmapped ID resolution reads immutable kModuleTable without data races, returns without mutating state, and mapped IDs continue to synchronize on gMutex when inspecting gLoadCount. - Verified cross-platform LP64 and LLP64 type safety in core/libs/prx/libSceSysmodule/Export.cpp:33 and core/libs/tests/GuestSysmodule.cpp:63: kMeasuredInternalUnloadedModuleId is explicitly typed as constexpr std::uint32_t with literal 0x800000c4u, matching the uint32_t parameter type without sign extension or truncation. - Verified test coverage in core/libs/tests/GuestSysmodule.cpp:321: Require(sceSysmoduleIsLoadedInternal(kMeasuredInternalUnloadedModuleId) == kModuleUnloaded) directly exercises the new unloaded branch without altering global state or impacting subsequent module lifecycle tests. - Verified compliance with AGENTS.md: confirmed no comments were added in code in Export.cpp or GuestSysmodule.cpp, no unauthorized files were created, and docs/dev/debt/libSceSysmodule.md was updated to reflect the remaining throwing internal variants. - Note: the AI-assisted checkbox can stay. Looks Good To Me
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!19323
No description provided.