fix(agc): write nothing for an empty register list #6004
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6004"
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 XairRrR on 2026-10-14T18:52:33Z.
What
Agc::Command::WriteRegisters, behindsceAgcCbSetShRegistersDirect,sceAgcCbSetUcRegistersDirectand thesceAgcDcbSet{Cx,Sh,Uc}RegisterDirectwriters, threwempty register liston a count of 0, although the matching...GetSizefunctions already report 0 bytes for it (agc_register_command_testschecks that). PPSA05684 (Uncharted: Legacy of Thieves Collection) callssceAgcCbSetShRegistersDirectwith an empty list at its main menu and terminated withwhat(): sceAgcCbSetShRegistersDirect: empty register list.An empty list now writes no packet, leaves the buffer untouched and returns its cursor, as its size says; a null buffer still throws. No packet is the behaviour the size function implies; the console's own return value for an empty list is not measured.
Tested
main2b7e3ce69: full ctest 1182 of 1182,tools/check_conventions.py --base origin/mainpasses.agc_register_command_testsnow writes an empty list through each writer into a sentinel-filled buffer and requires the returned pointer to be the cursor, the cursor unchanged and the sentinel intact. WithPacket.cppfrommainit fails withsceAgcCbSetShRegistersDirect: empty register list.mainplus #757/#758): the main menu no longer terminates on this call.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 Dextroid17 on 2026-10-14T22:18:51Z.
Measured on this branch (
cf914b510, 238 commits behind main), default CMake build (CMAKE_BUILD_TYPE empty, so unoptimized), lavapipe not involved (command-buffer encoding only), CachyOS Linux 7.2.9,agc_register_command_tests, rebuilt:Packet.cpptaken from main and the new test kept: the added call throws main'ssceAgcCbSetShRegistersDirect: empty register listand the test exits 1. That matches the PR body.I read the change: a count of 0 now returns
buffer->cursor_upwithout writing, and a null buffer still throws (by reading; no test covers a null buffer with count 0). That agrees with...GetSize(0) == 0, which the existing test already requires.Not checked: what the console returns for an empty list (the PR body says the same), the title run on PPSA05684, and other targets.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-15T00:54:53Z.
Thanks for measuring it. The null-buffer case is now covered:
f991052cfaddsexpectFailure([&] { writers[i](nullptr, nullptr, 0); })next to the empty-list check, for all three writers. With theRequire(buffer != nullptr, ...)line removed fromWriteRegistersthe test crashes (segfault onbuffer->cursor_up); with it, it passes.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-16T11:41:45Z.
Thanks, that closes the gap I noted. Re-run at
f991052cfas-is (merge base2b7e3ce69, not rebased onto currentmain), Release build, Linux (CachyOS, kernel 7.2.9),agc_register_command_tests:Require(buffer != nullptr, ...)line in thecount == 0branch ofWriteRegistersremoved, the test segfaults (exit 139), 3 of 3, as you describe.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T20:51:00Z.
Checked on the PR merged onto current
main:agc_register_command_testspasses, and withPacket.cppreverted the new empty-list check fails. Empty list returns the cursor without writing, null buffer still throws, which matches what the...GetSizefunctions report; merging.