Repository navigation
feat(libc): implement std::_Throw(const std::bad_array_new_length&) - #10927
Conversation
Progress report (3a2b919 → f94297b)📈 System libraries: 45.91% (+0.0037%, +1 implemented functions) ✅ 1 implemented
Changed libraries (implemented exports)
|
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
1a6d689 to
5710c87
Compare
|
Overlap note: |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed exact head 5710c87e1aad77032f6d0e0484494220a8ddfb3a. The export body reuses the existing ThrowPlain path with _ZTVSt20bad_array_new_length, and the type record correctly derives from bad_alloc; the static console evidence and scope are clearly described. I ran g++ -std=c++20 -Wall -Wextra -Werror -Icore/libs -fsyntax-only core/libs/tests/GuestThrowBadArrayNewLength.cpp, tools/check_conventions.py --base upstream/main --head HEAD, and git diff --check upstream/main...HEAD; all passed. I could not run the linked CTest target in this checkout because the third-party submodules are uninitialized.
One test gap: GuestThrowBadArrayNewLength.cpp catches ..., so it passes if the export throws a different exception type (for example, bad_alloc) even though the purpose of this symbol is to throw std::bad_array_new_length. Please assert the caught dynamic type, and fail if a different exception is caught; retaining the RTTI/vtable layout checks is useful but does not verify the type thrown by this entry point.
|
Pushed The Verification:
The RTTI/vtable layout and base-type checks are unchanged. Not run: |
|
Windows run of head
AI-assisted: yes (Claude Code); results above were run on this machine. |
|
The test gap from the review is addressed at |
c437e5a to
8a22e09
Compare
|
Rebased onto current |
8a22e09 to
93c5eba
Compare
|
Rebased onto current
|
|
Rebased onto current |
9cc1507 to
96e0a37
Compare
|
Rebased onto current |
96e0a37 to
ab17f79
Compare
|
Rebased again onto current |
ab17f79 to
b329765
Compare
|
Rebased automatically onto current |
|
Rebased automatically onto current |
b14481c to
031c83f
Compare
|
Rebased automatically onto current |
031c83f to
e1b5aa8
Compare
|
Rebased automatically onto current |
e1b5aa8 to
88df37c
Compare
|
Rebased automatically onto current |
88df37c to
bce1351
Compare
|
Rebased automatically onto current |
bce1351 to
7daa9d7
Compare
|
Rebased automatically onto current |
7daa9d7 to
d0ffc18
Compare
|
Rebased automatically onto current |
d0ffc18 to
91a46e5
Compare
|
Rebased automatically onto current |
91a46e5 to
f14c754
Compare
|
Rebased automatically onto current |
f14c754 to
490e813
Compare
Follow the console libc.prx (PPSA02530) at 0xcb2d0: ignore the argument and throw the static bad_array_new_length object. Star Wars Racer (PPSA28416) imports it.
|
Rebased automatically onto current |
490e813 to
f94297b
Compare
XairRrR
left a comment
There was a problem hiding this comment.
Reviewed — approved
The export is correct (NID 1cKlQv7Kvmg matches the name, it throws std::bad_array_new_length through the existing ThrowPlain path), it merges cleanly onto current main, and the new test passes and fails under two negative controls. I have one non-blocking note on the wording of the debt entry.
What I ran
Head f94297b8c2138ef9b963c8e25f9df7f40ab132da merged (--no-ff) onto main d71fe2fa87f8d74b14ad86506b5f0ed916b33a70 in a clean worktree. Arch Linux 7.2.11-zen, GCC 16.2.1, Intel Core i9-14900KF, Release, Ninja, BUILD_TESTING=ON.
git fetch origin main pull/10927/head:refs/review/10927
git checkout --detach origin/main
git merge --no-ff --no-edit refs/review/10927
git diff --check origin/main...refs/review/10927
python3 tools/check_conventions.py --base origin/main
cmake -S . -B build
cmake --build build -j10 --target guest_throw_bad_array_new_length_tests guest_bad_optional_access_tests exception_runtime_tests libs
ctest --test-dir build -j4 --output-on-failure -R "guest_throw_bad_array_new_length|guest_bad_optional_access|exception_runtime"
nm -D build/core/libs/libs/libc.prx | grep 1cKlQv7Kvmg
# NID: SHA-1(name + 518D64A635DED8C1E6B039B1C3E55230), first 8 bytes as LE u64, BE base64, '/' -> '-'Results
| Check | Result |
|---|---|
Merge onto main |
Clean (core/libs/prx/libc/CMakeLists.txt auto-merged) |
git diff --check |
Clean |
check_conventions.py --base origin/main |
All conventions checks passed |
Build (libs and the three test targets) |
OK, no warnings in the changed files |
guest_throw_bad_array_new_length |
Passed (0.00 s) |
guest_bad_optional_access, exception_runtime |
Passed |
NID of _ZSt6_ThrowRKSt20bad_array_new_length |
Computes to 1cKlQv7Kvmg, matches the description and debt entry |
Export in the built libc.prx |
0000000000108020 T 1cKlQv7Kvmg |
ctest
1/3 Test #627: guest_bad_optional_access .......... Passed 0.00 sec
2/3 Test #629: guest_throw_bad_array_new_length ... Passed 0.00 sec
3/3 Test #633: exception_runtime .................. Passed 0.00 sec
100% tests passed out of 3
Negative control
- I restored
core/libs/prx/libc/include/Api.hppandcore/libs/prx/libc/src/exception/StandardExceptions.cppfrommain. The test no longer compiles (_ZSt6_ThrowRKSt20bad_array_new_length_nid_postfixnot declared). This matches the Windows result reported earlier in the thread. - That only shows that the test needs the symbol, so I also checked the type assertion. I changed the new export's body to throw
std::bad_alloc(ThrowPlain(_ZTVSt9bad_alloc_nid_postfix)) and rebuilt.guest_throw_bad_array_new_lengththen fails (Subprocess aborted). This confirms the fix for the earlier review'scatch (...)gap: the test now rejects the base type. With the file restored, the test passes again.
Findings
Blocking
None.
Non-blocking
docs/dev/debt/libc.md:194: the entry describes the console function and the implementation but never names a gap. CONTRIBUTING.md asks that an entry "states the gap first (what differs from the console, what is unverified, what throws)". The open point is that the evidence is static disassembly of thelibc.prxbundled with PPSA02530, while the importer is PPSA28416, and it was not checked at runtime. Suggested wording: lead with "Unverified at runtime; follows static disassembly of thelibc.prxbundled with PPSA02530 …". Alternatively, if maintainers consider the behaviour settled, drop the entry and keep the evidence in the PR body.
Not verified
- Windows and macOS builds. Windows runs were reported in the thread by two contributors; I did not repeat them.
- The console disassembly of
libc.prx(PPSA02530,0xcb2d0). I have no copy and took the description's reading as given. - Running PPSA28416. Not done, per review policy.
|
Checked the export against the existing |
What
Implement
_ZSt6_ThrowRKSt20bad_array_new_length(1cKlQv7Kvmg), imported by Star Wars Racer (PPSA28416) fromlibc.The
libc.prxbundled with PRAGMATA PPSA02530 exports it as a 52-byte function at0xcb2d0(static disassembly): it ignores its argument, allocates the 8-byte exception object, installs the static_ZTVSt20bad_array_new_length, and calls__cxa_throw. The implementation reusesLibcException::ThrowPlainwith that vtable, the same path as__cxa_throw_bad_array_new_length; the argument is deliberately unused, as on the console. A guest test checks the type record, base (std::bad_alloc), vtable and that the call throws, and the debt entry records the console evidence.Overlap: #9416 adds a
void*placeholder for_ZSt6_ThrowRKSt20bad_array_new_lengthtolibc/Export.cppthat throwsstd::runtime_error; I asked its author to drop it (#9416 (comment)). This PR is the real implementation and does not build on #9416, but the two exports cannot both land. #9416 also already conflicts with currentmainon theErrorCodelayout (pre-existing, not caused by this PR). The otherdocs/dev/debt/libc.mdandCMakeLists.txtoverlaps are unrelated entries.Tested
Linux, CachyOS 7.3.0, GCC 16.2.1,
mainb2c7a38840+ this PR:guest_throw_bad_array_new_lengthpasses.guest_bad_optional_accesspasses.python3 tools/check_conventions.py --base origin/mainpasses.The console evidence is static disassembly of the retail
libc.prx, not a live console measurement; the title itself was not run.Checklist
main; no other open PR implements itNotImplemented_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)