fix(json2): return parse error on null text or zero size #7372

Merged
pushkarreddyy merged 1 commit from upstream-pr/7372 into main 2026-10-18 09:22:51 +00:00
pushkarreddyy commented 2026-10-18 03:13:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-18T03:13:11Z.


What

In NHL 26 (PPSA26785, Discussion #7304), execution halts ~4m56s in (after the legal/licence screen) on an unhandled exception:

terminate called after throwing an instance of 'std::invalid_argument'
what(): sce::Json::Parser::parse: null text from libSceJson2.prx+0x1976c

_ZN3sce4Json6Parser5parseERNS0_5ValueEPKcm previously threw host std::invalid_argument("sce::Json::Parser::parse: null text") when passed a null text pointer. The console's libSceJson2 returns an error status rather than throwing host C++ exceptions into the guest runtime, which causes an unhandled abort.

This change returns JsonErrorParse (0x80920101) when text == nullptr || size == 0, leaving the output Value untouched.

Tested

  • Added unit tests in core/libs/tests/GuestJson.cpp validating that Parser::parse with (nullptr, 0), (nullptr, 10), and ("", 0) returns < 0 and preserves existing Value contents.
  • python tools/check_conventions.py --base origin/main passes with 0 findings.

Checklist

  • Depends on: none
  • AI-assisted: yes
  • Unblocks: PPSA26785 #7304
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4905992303 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7372). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-18T03:13:11Z. --- ### What In *NHL 26* (PPSA26785, Discussion #7304), execution halts ~4m56s in (after the legal/licence screen) on an unhandled exception: ```text terminate called after throwing an instance of 'std::invalid_argument' what(): sce::Json::Parser::parse: null text from libSceJson2.prx+0x1976c ``` `_ZN3sce4Json6Parser5parseERNS0_5ValueEPKcm` previously threw host `std::invalid_argument("sce::Json::Parser::parse: null text")` when passed a null text pointer. The console's `libSceJson2` returns an error status rather than throwing host C++ exceptions into the guest runtime, which causes an unhandled abort. This change returns `JsonErrorParse` (`0x80920101`) when `text == nullptr || size == 0`, leaving the output `Value` untouched. ### Tested - Added unit tests in `core/libs/tests/GuestJson.cpp` validating that `Parser::parse` with `(nullptr, 0)`, `(nullptr, 10)`, and `("", 0)` returns `< 0` and preserves existing `Value` contents. - `python tools/check_conventions.py --base origin/main` passes with 0 findings. ### Checklist - [x] Depends on: none - [x] AI-assisted: yes - [x] Unblocks: PPSA26785 #7304
oneandonlydean commented 2026-10-18 03:22:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T03:22:59Z.


Thanks, the fix looks right. One request: please drop the title id from the debt entry, since we keep game titles out of docs (title-specific notes go in the Game bring-up discussion, https://github.com/boykopovar/AnyPS5/discussions/7304 here). For example: "a null text pointer or zero size returns JsonErrorParse (0x80920101) without modifying the destination Value; whether the console uses a separate parameter error code for a null pointer is unknown."

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6245149860 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7372#issuecomment-6245149860). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-18T03:22:59Z. --- Thanks, the fix looks right. One request: please drop the title id from the debt entry, since we keep game titles out of docs (title-specific notes go in the Game bring-up discussion, https://github.com/boykopovar/AnyPS5/discussions/7304 here). For example: "a null text pointer or zero size returns `JsonErrorParse` (0x80920101) without modifying the destination Value; whether the console uses a separate parameter error code for a null pointer is unknown."
github-actions[bot] commented 2026-10-18 03:32:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T03:32:32Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6039 docs/dev/debt/libSceJson2.md
PR 6044 core/libs/tests/GuestJson.cpp
PR 6447 core/libs/prx/libSceJson2/Export.cpp
docs/dev/debt/libSceJson2.md
PR 6964 docs/dev/debt/libSceJson2.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6245222969 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7372#issuecomment-6245222969). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-18T03:32:32Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 6039](https://www.github.com/boykopovar/AnyPS5/pull/6039) | `docs/dev/debt/libSceJson2.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestJson.cpp` | | [PR 6447](https://www.github.com/boykopovar/AnyPS5/pull/6447) | `core/libs/prx/libSceJson2/Export.cpp`<br>`docs/dev/debt/libSceJson2.md` | | [PR 6964](https://www.github.com/boykopovar/AnyPS5/pull/6964) | `docs/dev/debt/libSceJson2.md` |
MarcZX10 commented 2026-10-18 03:34:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T03:34:32Z.

Review: COMMENTED


Small test suggestion: since the PR specifies JsonErrorParse (0x80920101), could the three new assertions compare the return value to JsonErrorParse instead of only checking < 0? That would pin the stated error contract and catch a different failure code.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5561281368 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7372#pullrequestreview-5561281368). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-18T03:34:32Z. **Review:** COMMENTED --- Small test suggestion: since the PR specifies `JsonErrorParse` (`0x80920101`), could the three new assertions compare the return value to `JsonErrorParse` instead of only checking `< 0`? That would pin the stated error contract and catch a different failure code.
pushkarreddyy commented 2026-10-18 04:14:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-18T04:14:37Z.


Done! Dropped the title ID from the debt entry in docs/dev/debt/libSceJson2.md and force-pushed the updated commit.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6245548762 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7372#issuecomment-6245548762). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-18T04:14:37Z. --- Done! Dropped the title ID from the debt entry in `docs/dev/debt/libSceJson2.md` and force-pushed the updated commit.
pushkarreddyy commented 2026-10-18 04:21:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-18T04:21:49Z.


Updated the three assertions in GuestJson.cpp to verify exact equality with JsonErrorParse (== JsonErrorParse) as suggested by @MarcZX100, and verified tools/check_conventions.py passes cleanly with 0 findings.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6245602618 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7372#issuecomment-6245602618). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-18T04:21:49Z. --- Updated the three assertions in `GuestJson.cpp` to verify exact equality with `JsonErrorParse` (`== JsonErrorParse`) as suggested by @MarcZX100, and verified `tools/check_conventions.py` passes cleanly with 0 findings.
MarcZX10 commented 2026-10-18 04:23:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T04:23:24Z.


Thanks for updating the three assertions to compare against JsonErrorParse, and for removing the title ID from the debt entry. I checked the current diff; those changes address both review points, and I have no further request on this patch.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6245614402 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7372#issuecomment-6245614402). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-18T04:23:24Z. --- Thanks for updating the three assertions to compare against `JsonErrorParse`, and for removing the title ID from the debt entry. I checked the current diff; those changes address both review points, and I have no further request on this patch.
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!7372
No description provided.