fix(json2): preserve values when type allocation fails #7977
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7977"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-19T16:41:46Z.
What
Value::set(ValueType)clears the existing value and publishes the requested type before allocating its empty String, Array or Object storage. If allocation throws, the destination loses its previous contents and retains a type with null storage.Construct the replacement storage before clearing the destination, then transfer it while preserving the per-value handlers. Extend the existing
JsonCopyFailurefixture with the three type setter paths, checking that failures preserve the old type and serialized value and release all tracked allocations.The author of #7477 confirmed that either merge order works. I verified that its current head
2a1ca278eefad1e84aff2801e44442fdb406d12dleavesSetTypeandJsonCopyFailure.cppidentical to main and combines cleanly with this patch.The overlap tool reports #7215 as a shared file it cannot compare because that branch conflicts with main. I compared its diff manually: it changes numeric conversion in
RealTextandParser::number, plus includes, and does not changeSetTypeor the allocation failure fixture. There is no dependency on either PR.Tested
Tested revision:
51e75dec2591d1b884c541f48cdfdd2431bdf0eb, based ond047690c6391577c9add655ae1dc2ed20df177a8. Full native Windows configuration: Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0, Release/O3,BUILD_TESTING=ON.Hardware: Ryzen 9 7900X, 32 GB RAM, GeForce RTX 4070 Ti SUPER.
guest_json,guest_json_copy_failureandpatched_libraries: 3/3 passed, no skips.set empty array budget=0: failed setter changed the destination type(basebcdee66d109008334b07c0ff73a27e845708675f). The JSON implementation and original fixture are byte-identical in that base and the rebased base.python3 tools/check_conventions.py --base origin/mainpassed.python3 tools/pr_overlap.py --branch codex/fix-json2-type-allocationcompleted; its remaining #7215 warning was reviewed as described above.Linux, PRAGMATA gameplay and the complete CTest suite were not run.
Reproduction commands, using
buildas the build directory and the documented toolchain on PATH: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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-19T16:42:51Z.
Review: COMMENTED
I reviewed the exception-safety path at the current head.
SetTypenow validates before mutation, constructs the replacement payload before clearing the old node, and transfers the existing handlers afterClearpreserves them. The new allocation-failure cases check both the previous type and serialized value for string, array, and object setters, which covers the destructive failure mode. I did not independently run the reported Windows build/tests; the PR description identifies the tested revision and notes Linux/gameplay were not run.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T23:08:02Z.
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.
core/libs/prx/libSceJson2/Export.cpp