fix(json): implement allocator error notification #2308

Closed
yeahboi233 wants to merge 1 commit from upstream-pr/2308 into main
yeahboi233 commented 2026-10-09 15:14:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by yeahboi233 on 2026-10-09T15:14:31Z.


What

Calling the existing sce::Json::MemAllocator::notifyError export raises a not-implemented exception instead of reporting the allocation error. Implement its default notification by printing the error code and requested byte count to stdout, returning normally and leaving allocator/user-data storage untouched.

Replace the parameterless, integer-returning placeholder with a void callback taking the implicit allocator pointer, error code, 64-bit requested size and user-data pointer. The argument types come from the existing PS5 mangled export; the void return and default printing behavior come from the related VitaSDK JSON API. TechnicalDebt records that the PS5 return contract and exact diagnostic wording remain unverified on hardware.

This implements one existing gray cell in the JSON library: 92/94 to 93/94 functions in the progress report. It does not change JSON allocation or dispatch custom allocator callbacks. #992 originally declared this throwing import. No title-compatibility or unresolved-import fix is claimed.

Tested

macOS 26.6.2, Apple Silicon, AppleClang 21, current main d70b89989473ba1f6ae13e44e079e67f1f8a44b0:

  • The new checks in the existing GuestJson.cpp test fail on the original production stub with its not-implemented exception.
  • Production Export.cpp plus the complete GuestJson.cpp passes in an arm64 Release build (-O2 -DNDEBUG), arm64 AddressSanitizer/UBSan build, and x86-64 Release build executed through the already installed Rosetta.
  • Five notification cases cover signed error limits, zero size, a size beyond 32 bits, maximum size_t, null/non-null user data, diagnostic contents, normal return and unchanged opaque storage. Existing JSON checks still run.
  • Direct Mac builds link an external test-only implementation of NotImplemented_nid_no_patch that throws for the remaining unrelated RTTI stub. They exercise the production JSON source; they do not constitute the full runtime build or patched .prx loader validation.
  • Convention checks and git diff --check pass. The existing guest_json CTest registration runs the added checks in a full build.

Full Linux/Windows builds and console/game execution have not been run locally. Native Windows stdout capture and the guest calling convention need their platform checks.

Checklist

  • Based on current main; open-PR overlap checked before submission, with the later concurrent #2309 overlap recorded below
  • 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 in TechnicalDebt
  • 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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes; implementation, tests and description were written with Codex assistance

Open-PR overlap

The overlap bot reports #2281 and #2309. Neither is a dependency of this implementation.

  • #2281 changes sceNetResolverAbort and removes that entry from the same one-line unknown-signature list in TechnicalDebt.md from which this PR removes notifyError. The source and tests are separate. When both changes are integrated, the documentation list must omit both entries and retain both functions' individual uncertainty notes.
  • #2309 opened at 15:17:21 UTC on October 9, after this PR opened at 15:14:31 UTC. It also changes the exact notifyError export and test declaration. Its current implementation discards the error code, requested size and user data, and validates the allocator pointer without printing a notification; this PR implements the default stdout diagnostic described by the related VitaSDK API and tests its contents. The two alternatives cannot merge unchanged. This PR does not incorporate #2309's separately inferred RTTI constructor layout.

Depends on: none remains accurate. The shared export is a competing implementation requiring a maintainer choice or removal from one PR; declaring a dependency solely to suppress the bot would not reconcile the behavior.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4802327050 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2308). Originally posted by [yeahboi233](https://github.com/yeahboi233) on 2026-10-09T15:14:31Z. --- ### What Calling the existing `sce::Json::MemAllocator::notifyError` export raises a not-implemented exception instead of reporting the allocation error. Implement its default notification by printing the error code and requested byte count to stdout, returning normally and leaving allocator/user-data storage untouched. Replace the parameterless, integer-returning placeholder with a void callback taking the implicit allocator pointer, error code, 64-bit requested size and user-data pointer. The argument types come from the existing PS5 mangled export; the void return and default printing behavior come from the related [VitaSDK JSON API](https://docs.vitasdk.org/group__SceLibJsonUser.html). TechnicalDebt records that the PS5 return contract and exact diagnostic wording remain unverified on hardware. This implements one existing gray cell in the JSON library: 92/94 to 93/94 functions in the progress report. It does not change JSON allocation or dispatch custom allocator callbacks. #992 originally declared this throwing import. No title-compatibility or unresolved-import fix is claimed. ### Tested macOS 26.6.2, Apple Silicon, AppleClang 21, current main `d70b89989473ba1f6ae13e44e079e67f1f8a44b0`: - The new checks in the existing `GuestJson.cpp` test fail on the original production stub with its not-implemented exception. - Production `Export.cpp` plus the complete `GuestJson.cpp` passes in an arm64 Release build (`-O2 -DNDEBUG`), arm64 AddressSanitizer/UBSan build, and x86-64 Release build executed through the already installed Rosetta. - Five notification cases cover signed error limits, zero size, a size beyond 32 bits, maximum `size_t`, null/non-null user data, diagnostic contents, normal return and unchanged opaque storage. Existing JSON checks still run. - Direct Mac builds link an external test-only implementation of `NotImplemented_nid_no_patch` that throws for the remaining unrelated RTTI stub. They exercise the production JSON source; they do not constitute the full runtime build or patched `.prx` loader validation. - Convention checks and `git diff --check` pass. The existing `guest_json` CTest registration runs the added checks in a full build. Full Linux/Windows builds and console/game execution have not been run locally. Native Windows stdout capture and the guest calling convention need their platform checks. ### Checklist - [x] Based on current `main`; open-PR overlap checked before submission, with the later concurrent #2309 overlap recorded below - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes; implementation, tests and description were written with Codex assistance ### Open-PR overlap The overlap bot reports #2281 and #2309. Neither is a dependency of this implementation. - #2281 changes `sceNetResolverAbort` and removes that entry from the same one-line unknown-signature list in `TechnicalDebt.md` from which this PR removes `notifyError`. The source and tests are separate. When both changes are integrated, the documentation list must omit both entries and retain both functions' individual uncertainty notes. - #2309 opened at 15:17:21 UTC on October 9, after this PR opened at 15:14:31 UTC. It also changes the exact `notifyError` export and test declaration. Its current implementation discards the error code, requested size and user data, and validates the allocator pointer without printing a notification; this PR implements the default stdout diagnostic described by the related VitaSDK API and tests its contents. The two alternatives cannot merge unchanged. This PR does not incorporate #2309's separately inferred RTTI constructor layout. `Depends on: none` remains accurate. The shared export is a competing implementation requiring a maintainer choice or removal from one PR; declaring a dependency solely to suppress the bot would not reconcile the behavior.
github-actions[bot] commented 2026-10-09 15:14:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T15:14:55Z.


Progress report (d70b899 → a979c66)

📈 System libraries: 84.72% (+0.03%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceJson2 _ZN3sce4Json12MemAllocator11notifyErrorEimPv
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6083742049 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2308#issuecomment-6083742049). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T15:14:55Z. --- <!-- progress-report --> ### Progress report (d70b899 → a979c66) 📈 **System libraries**: 84.72% (+0.03%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libSceJson2 | `_ZN3sce4Json12MemAllocator11notifyErrorEimPv` | </details>
github-actions[bot] commented 2026-10-09 15:29:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T15:29:46Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#2281 docs/dev/TechnicalDebt.md L59
#2309 core/libs/tests/GuestJson.cpp L88
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6083996746 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2308#issuecomment-6083996746). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T15:29:46Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #2281 | `docs/dev/TechnicalDebt.md` [L59](https://github.com/boykopovar/AnyPS5/blob/8b393b6e9a8ade9188d4f74a0293e0efd9828597/docs/dev/TechnicalDebt.md#L59) | | | | #2309 | `core/libs/tests/GuestJson.cpp` [L88](https://github.com/boykopovar/AnyPS5/blob/8b393b6e9a8ade9188d4f74a0293e0efd9828597/core/libs/tests/GuestJson.cpp#L88) | | |
yeahboi233 commented 2026-10-09 16:17:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by yeahboi233 on 2026-10-09T16:17:19Z.


Following up on the overlap report:

  • #2281 conflicts only in the one-line unknown-signature list in TechnicalDebt.md: it removes sceNetResolverAbort, while this PR removes notifyError. The implementation and tests are independent. After either merges, I can rebase this PR and preserve both removals and both functions' limitation notes.
  • #2309 is a concurrent implementation of the same notifyError export. Its current implementation discards the error code and requested size without printing a notification. This PR prints the default diagnostic described by the related VitaSDK JSON API and tests the diagnostic, argument limits and unchanged opaque storage. The PS5-specific uncertainty remains documented. This PR leaves the unverified RTTI constructor unimplemented.

Neither PR is a dependency, so Depends on: none remains accurate. A maintainer choice or removal of the duplicated export from one PR is needed before both can merge.

The local arm64 Release, ASan/UBSan and x86-64 Rosetta JSON tests passed, as did the relinker CI matrix and conventions checks. Full Linux/Windows library builds were skipped by the automatic workflow. Could a collaborator run those full checks and review which notification implementation to retain?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6084790290 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2308#issuecomment-6084790290). Originally posted by [yeahboi233](https://github.com/yeahboi233) on 2026-10-09T16:17:19Z. --- Following up on the [overlap report](https://github.com/boykopovar/AnyPS5/pull/2308#issuecomment-6083996746): - #2281 conflicts only in the one-line unknown-signature list in `TechnicalDebt.md`: it removes `sceNetResolverAbort`, while this PR removes `notifyError`. The implementation and tests are independent. After either merges, I can rebase this PR and preserve both removals and both functions' limitation notes. - #2309 is a concurrent implementation of the same `notifyError` export. Its current implementation discards the error code and requested size without printing a notification. This PR prints the default diagnostic described by the related [VitaSDK JSON API](https://docs.vitasdk.org/group__SceLibJsonUser.html) and tests the diagnostic, argument limits and unchanged opaque storage. The PS5-specific uncertainty remains documented. This PR leaves the unverified RTTI constructor unimplemented. Neither PR is a dependency, so `Depends on: none` remains accurate. A maintainer choice or removal of the duplicated export from one PR is needed before both can merge. The local arm64 Release, ASan/UBSan and x86-64 Rosetta JSON tests passed, as did the relinker CI matrix and conventions checks. Full Linux/Windows library builds were skipped by the automatic workflow. Could a collaborator run those full checks and review which notification implementation to retain?
AnzouBelilita commented 2026-10-09 16:40:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AnzouBelilita on 2026-10-09T16:40:20Z.


Independent Windows validation for PR #2308:

  • OS: Windows 10 Pro, build 19045
  • Toolchain: MinGW-w64 GCC 16.2.0, CMake 4.4.4, Ninja 1.13.2
  • Configured the project successfully in Release mode with BUILD_TESTING=ON.
  • Built the guest_json_tests target successfully (96 build steps).
  • CTest: guest_json passed (1/1, 0 failures).
  • python tools/check_conventions.py --base d70b89989473ba1f6ae13e44e079e67f1f8a44b0 passed.
  • git diff --check d70b89989473ba1f6ae13e44e079e67f1f8a44b0...HEAD passed.

This independently confirms that the PR builds and its JSON tests pass on native Windows. It does not verify the PS5-specific calling convention or exact behavior on console hardware.

No production code was modified during validation.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6085157725 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2308#issuecomment-6085157725). Originally posted by [AnzouBelilita](https://github.com/AnzouBelilita) on 2026-10-09T16:40:20Z. --- Independent Windows validation for PR #2308: * OS: Windows 10 Pro, build 19045 * Toolchain: MinGW-w64 GCC 16.2.0, CMake 4.4.4, Ninja 1.13.2 * Configured the project successfully in Release mode with `BUILD_TESTING=ON`. * Built the `guest_json_tests` target successfully (96 build steps). * CTest: `guest_json` passed (1/1, 0 failures). * `python tools/check_conventions.py --base d70b89989473ba1f6ae13e44e079e67f1f8a44b0` passed. * `git diff --check d70b89989473ba1f6ae13e44e079e67f1f8a44b0...HEAD` passed. This independently confirms that the PR builds and its JSON tests pass on native Windows. It does not verify the PS5-specific calling convention or exact behavior on console hardware. No production code was modified during validation.
oneandonlydean commented 2026-10-09 20:11:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:11:42Z.


Closing: no title calls MemAllocator::notifyError on main, so the only effect is +1 in the progress report. Please reopen with the title ID and the log line if one reaches it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088467224 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2308#issuecomment-6088467224). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T20:11:42Z. --- Closing: no title calls `MemAllocator::notifyError` on main, so the only effect is +1 in the progress report. Please reopen with the title ID and the log line if one reaches it.

Pull request closed

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!2308
No description provided.