Skip to content

fix(json2): release partial entries on allocation failure - #8530

Open
Ondra97 wants to merge 1 commit into
boykopovar:mainfrom
Ondra97:codex/fix-json2-parse-allocation
Open

Ondra97 wants to merge 1 commit into
boykopovar:mainfrom
Ondra97:codex/fix-json2-parse-allocation

Conversation

@Ondra97

@Ondra97 Ondra97 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What

Json2 array parsing constructs each value before linking it into its owning list. If list-node allocation fails, destination cleanup cannot reclaim that value. On the current main, parsing [1] with allocation budget 2 retains one allocation after cleanup.

Construct each array entry directly in its owning list so existing partial-tree cleanup owns it before further allocation. Current main already handles the object-entry failure paths from the original patch; retain its ordered object insertion, duplicate-key replacement and incremental parser behavior.

Extend allocation-failure coverage for valid and malformed documents, nested containers, long keys, callback reads and missing-key insertion. Preserve upstream iterator-copy and swap regressions. Check destination values, entry identity, container sizes and mismatch handlers after failures. Related to #8005, finding C9; no title, OOM or performance improvement is claimed.

Tested

Rebased on a6dcea9279b53b3a39c13695eac66f7c8b5b503c; tested head 1f0a363b503d5e689bae3a5667060b281a70fe9c.

Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0r7 UCRT, Release, full build configuration with BUILD_TESTING=ON. CPU: AMD Ryzen 9 7900X; RAM: 32 GB; GPU: NVIDIA GeForce RTX 4070 Ti SUPER.

The final allocation-failure regression fails with unchanged current-main production code at parse array budget=2: operation leaked allocations. With the fix it covers 37 operations and 549 forced allocation failures with no tracked leaks. The parser checks use current-main error codes, callback error propagation and acceptance of trailing input.

The production build (libs, relinker, patched-library fixture and both Json2 fixtures) passes. All three registered runtime tests pass without skips (3/3, 0.66 s). Conventions, main-sync and whitespace checks pass. The overlap checker flags conflicting #7215 and this PR itself; manual review confirms #7215 changes numeric locale conversion and does not implement allocation ownership.

cmake --build build --target libs relinker patched_libraries_tests guest_json_tests guest_json_copy_failure_tests --parallel 8
ctest --test-dir build -R "^(guest_json|guest_json_copy_failure|patched_libraries)$" -V --output-on-failure --no-tests=error
python -B tools/check_conventions.py --base origin/main
python -B tools/check_main_sync.py --base origin/main
python -B tools/pr_overlap.py --branch codex/fix-json2-parse-allocation --repo boykopovar/AnyPS5 --jobs 3
git diff --check origin/main...HEAD

The default all-target build, complete CTest suite and game/title runs were not performed on this rebased head.

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

@Ondra97

Ondra97 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Could someone help establish the PS5 Json2 allocator/initialization contract for the separate C2 follow-up in #8005? This is a contract question for that follow-up; the implementation in this PR covers allocation-failure ownership.

On tested revision c9f680fb, a synthetic parse/serialize probe performs 21 tracked host C++ allocations and makes zero calls to the supplied allocator's allocate/free/notify callbacks. Both the normal and null-returning callback settings still give successful initialize/parse results. Since no callback runs, this confirms ignored configuration but does not validate the candidate callback ABI.

I need to establish:

  • The allocator virtual-method signatures and alignment requirements, allocation-failure reporting, and how the RTTI allocator variant differs.
  • Whether initialization state is global or per Initializer, and the required allocator/object lifetime across repeated initialize/terminate calls and reinitialization with live Values.
  • Which parser overloads consume fileBufferSize, including what a zero size means.
  • The allowed SpecialFloatFormatType values and their behavior, especially value 2 in the supplied initialization configuration.

An API reference or results from a small PS5 test covering these cases would help me implement the general behavior and add a regression that fails before the fix and passes afterward. The synthetic probe uses no title assets.

@Ondra97
Ondra97 force-pushed the codex/fix-json2-parse-allocation branch from d28dc66 to 1f0a363 Compare October 21, 2026 23:35
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 22, 2026
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

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 9826 core/libs/prx/libSceJson2/Export.cpp

@oneandonlydean oneandonlydean self-assigned this Oct 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants