docs(libSceJsc): record the 32-bit wrap of the JSString maximum UTF-8 size #15708
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15708"
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 MarcZX10 on 2026-11-04T08:46:26Z.
What
docs(libSceJsc): records in the debt list thatJSStringGetMaximumUTF8CStringSizestill computes3 * length + 1instd::uint32_t, so the result wraps for strings longer than about 1.43e9 UTF-16 code units. The code keeps main's 32-bit behaviour, as the reviewers asked; the change tosize_tand the 2.9 GB test were removed from this PR.Tested
git diff --checkpass againstupstream/main.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)AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-07T18:59:22Z.
Review: CHANGES_REQUESTED
Not merging yet; the open question from @oneandonlydean's review still stands:
core/libs/prx/libSceJsc/Export.cpp:121: JavaScriptCore computesstring->length() * 3 + 1withlength()returningunsigned, so it wraps above 1431655765 units; thestd::uint32_tarithmetic onmainmatches that. Widening tosize_tmakes us differ from JSC. Please show that the PS5 module returns the 64-bit value (disassembly of the export or a console run), or drop the code change. If it does differ from upstream, say so in the library's debt file.core/libs/tests/GuestJscString.cpp:231: the test allocates ~2.9 GB in one go, a risk underctest -jand on small runners. If kept, reach the length without that allocation, or run it alone and return 77 when the memory is not available.Thanks to @JJenkx for the Windows run and negative control.
Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-10T11:12:32Z.
Review: COMMENTED
Read
5e7615b3e9againstmain.Correctness. The 32-bit arithmetic on
mainis deliberate, not a bug. It came in with50c8d4cd8f("answer the JSString null and length cases as JavaScriptCore does"), and it matches the WebKit sources the debt file pins. In pinned WebKitf274ef4c03Source/JavaScriptCore/API/JSStringRef.cpp,JSStringGetMaximumUTF8CStringSizeisreturn string->length() * 3 + 1;, andOpaqueJSString::length()returnsunsigned. The product is therefore computed in 32 bits and wraps before it widens tosize_t. The PS5 11.x WebKit tree linked indocs/dev/debt/libSceJsc.mdhas the same two lines (JSStringRef.cppandOpaqueJSString.h,unsigned length()). For lengths of 1431655766 and up, the console library returns the wrapped value; with this changeExport.cpp:JSStringGetMaximumUTF8CStringSize_nid_postfixreturns the unwrapped one. Lengths up to 2147483635 are accepted (the debt entry's UTF-16 limit), so the range where the result differs is reachable.Test.
MaximumSizeAboveUInt32pins the non-WebKit result. It also allocates about 2.9 GB in a defaultctestrun. That is a lot for CI runners, and more under sanitizers.Suggestion. Keep
main's behaviour. If a test for this range is useful, pin the wrapped value against the WebKit line above and cite it in the debt entry. If the PS5 build is believed to differ, that needs a console measurement or a disassembly, not the generalsize_treading.Not run here; this is from reading the code.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T12:06:56Z.
Review: COMMENTED
Ran the debt fold check on this head. The new entry applies cleanly and matches the implementation’s 32-bit arithmetic. A console result remains unmeasured.
AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.