feat(libc): implement libc++ string buffer contents setter #28733
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28733"
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 Plyxen on 2026-12-03T08:04:29Z.
What
Implements
std::__1::basic_stringbuf<char>::str(const string&), one of the functions RetroArch's bring-up discussion lists as missing. #28677 (open) adds the getterstr() const; the two share no file exceptCMakeLists.txt.It follows libc++ 17.0.6: the string is assigned to the buffer's own string, which keeps its storage when that is large enough and otherwise grows to the capacity libc++ would choose, with the old storage released through guest
operator delete. An output buffer then fills its string to its capacity. The get and put areas and the high-water mark are set from the open mode, with the put position at the end forappandate. Setting the buffer's own string is handled, and a string whose fields contradict each other is refused before the object changes. Before anything is changed, the whole source is read once and the object's current fields are written back to it, so a source that can't be read or an object that can't be written is refused with the buffer's storage intact too. ligmaSec and CodeRabbit found that the first version had already changed the storage by then.Tested
guest_libcxx_stringbuf_setpasses on Windows 11 (GCC 15.2) and Ubuntu 24.04 under WSL2 (GCC 13.3). It checks eight combinations ofin,out,appandatewith empty, short, 22-byte, 23-byte and long strings, growing and shrinking in place, assigning the own string, that untouched fields keep their values, and that a refused call changes nothing. That now includes the reused storage: a read-only object with a shorter string, a longer one or its own string, and a source that can be read only in part.Controls for that check: with the first version's setter, and with only the write-back taken out, it fails on the read-only object (
check failed at line 264); with only the read taken out it fails on the source (line 283). The first control fails on both systems; the other two were run on Windows.The other
guest_libcxx_*tests andguest_libc_static_importspass too. Not tested: a title. No console measurement.The runs of the first version were in a tree with other open libc++ PRs merged, whose code this change doesn't use. The current version ran on Windows at this branch's head, and on Linux on
main35e34b1a7f0together with #28045:guest_libcxx_stringbuf_setandguest_libc_static_importspass on both. The otherguest_libcxx_*tests were not rerun.tools/pr_overlap.py --branchreports one-line textual conflicts inlibc/CMakeLists.txtandlibc.hppwith #28565, #28655, #28709 and #28710, which add an entry at the same place. Fourteen PRs that conflict withmaincouldn't be compared (#7447, #7715, #8150, #8965, #12682, #12688, #12700, #12717, #12849, #12965, #16791, #23395, #27164, #28051). They share onlylibc/CMakeLists.txt: I read their changes to it, which are on other lines, and none of their diffs namesbasic_stringbuf.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)🤖 Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T08:13:19Z.
Review: COMMENTED
I reproduced a partial update on Linux. With a read-only stringbuf object and a writable long-string allocation,
str()throwsstd::invalid_argumentbut has already replaced the allocation’s contents. The object still carries the old size and stream pointers.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T08:14:17Z.
Review: COMMENTED
Actionable comments
274b1880-e725-4978-ac72-63a5972956d4Reviewing files that changed from the base of the PR and between
b97867d3ceand7760b0e8b6.core/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/include/LibcxxStringbufSet.hppcore/libs/prx/libc/libc.hppcore/libs/prx/libc/src/LibcxxStringbufSet.cppcore/libs/prx/libc/tests/cmake/guest_libcxx_stringbuf_set.cmakecore/libs/tests/GuestLibcxxStringbufSet.cppdocs/dev/debt/changes/feat-libc-libcxx-stringbuf-set.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T08:22:58Z.
Review: APPROVED
Reviewed — looks good
The implementation and all seven changed files support the described setter behavior, with no verified blocking defects.
What I ran
Reviewed head
7760b0e8b645f4106c913d1791ca19f440b83e91; basemainwas not used for a merged preview. I used the pinnedrepo_read.pyreader and shell for read-only inspection. No tests, builds, or compilation were run.Results
Negative control
Not run; no source mutation or test execution was performed.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
The author's reported Windows and WSL test runs were not independently verified. No title-level behavior or console measurement was checked. Read all files listed under
reviewedinfiles.json;files.jsonlists no excluded files.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T18:36:30Z.
Review: COMMENTED
Actionable comments
f724d4af-7372-4a1a-b8d1-3367bd1d8121Reviewing files that changed from the base of the PR and between
7760b0e8b6and785b30e330.core/libs/prx/libc/src/LibcxxStringbufSet.cppcore/libs/tests/GuestLibcxxStringbufSet.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T18:55:32Z.
Review: COMMENTED
The revised setter verifies the source span and checks that the stream metadata can be written before it changes the backing string. That addresses the read-only-object case from my earlier review. The integrated Linux
guest_libcxx_stringbuf_setfixture passed at785b30e330, including the failure checks for a read-only stream and unreadable source storage.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T19:00:56Z.
Review: APPROVED
Reviewed — looks good
The setter’s storage handling, stream positions, and failure checks support merging at head
785b30e330881d85b99802ff074d6e0a13d0ba04.What I ran
Read the prepared diff and all seven files listed under
reviewedinfiles.json; that manifest lists no excluded files. Inspected targeted repository context withrepo_read.pyat the pinned head. No tests or builds were run.Files read:
core/libs/prx/libc/CMakeLists.txt,core/libs/prx/libc/include/LibcxxStringbufSet.hpp,core/libs/prx/libc/libc.hpp,core/libs/prx/libc/src/LibcxxStringbufSet.cpp,core/libs/prx/libc/tests/cmake/guest_libcxx_stringbuf_set.cmake,core/libs/tests/GuestLibcxxStringbufSet.cpp, anddocs/dev/debt/changes/feat-libc-libcxx-stringbuf-set.md.Results
Negative control
Not run by the reviewer; no test was executed.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
The author-reported Windows and WSL2 test runs were not independently verified. No title or physical console behavior was tested.
To get this to a good state
Nothing is required.