Repository navigation
fix(libSceNgs2.native): return the module's buffer and allocator errors from sceNgs2RackCreate and sceNgs2RackCreateWithAllocator - #20810
Conversation
…rs from sceNgs2RackCreate and sceNgs2RackCreateWithAllocator sceNgs2RackCreate checked the handle first and threw for a null buffer info, and a null host buffer threw later in Ngs2Place. sceNgs2RackCreateWithAllocator checked the handle first and threw for a null allocator or alloc handler. Both now return 0x804A8020 or 0x804A8023 before the null-handle check, as the system create calls already do, and a rack allocator without a free handler throws only after the option and system checks. CheckRackCreateArguments covers the order, and the Ngs2Custom num_buffers check passes a real buffer.
|
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.
|
…n sceNgs2RackCreate sceNgs2RackCreate dereferenced the guest Ngs2ContextBufferInfo pointer when it passed the buffer info to CreateRack, so an unmapped buffer info faulted the host. The struct is now copied in with ReadGuest and the local copy is passed on. An unreadable pointer returns SCE_NGS2_ERROR_INVALID_BUFFER_INFO, the code PR #20810 returns for a null buffer info. A null pointer keeps its current behaviour in this change. CreateRack copies the buffer info by value, so readable input behaves as before.
…sceNgs2RackCreateWithAllocator sceNgs2RackCreateWithAllocator called the allocator handlers through the guest pointer, so an unmapped allocator faulted the host. The allocator is now copied in with ReadGuest, and the handlers, the creation and the release all use the local copy. An unreadable allocator returns SCE_NGS2_ERROR_INVALID_BUFFER_ALLOCATOR, the code PR #20810 returns for a null allocator. A readable null allocator or a readable null handler keeps its current behaviour. CreateRack stores the allocator by value, so no pointer to the local outlives the call.
|
@MarcZX10 Merged |
|
Tested
AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports. |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the reviewed code and supplied test report support merging.
What I ran
Reviewed head 8e4e8c0b088c85108f31bfb68921e5f71d465471. No commands or tests were run in this review; the Windows test results below are author reported.
Results
| Check | Result | Note |
|---|---|---|
| Patch and changed code | passed | Four changed files read |
| Author reported tests | passed | 50/50 Ngs2 tests on Windows |
| Reviewer test run | not run | No local test execution |
Findings
Blocking
None.
Non-blocking
None.
Not verified
No Linux or macOS run, physical console behavior, or independent test execution was performed. The author reports testing the change on Windows 11 with GCC 15.2.0 and a negative control; those results were not reproduced here. All four files listed under reviewed in manifest.json were read: Rack.cpp, Ngs2Custom.cpp, Ngs2HandleErrors.cpp, and fix-libscengs2-rack-create-errors.md. files.json was not provided in the review folder, so excluded files were not verified.
To get this to a good state
Nothing is required.
…creation error checks
|
@MarcZX10 Merged |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
Head 24ee695, base main. The change returns the module's buffer and allocator errors from sceNgs2RackCreate and sceNgs2RackCreateWithAllocator, as the description states, and the code I read does what it says.
What I ran
- Read the title and description, the commit list,
manifest.json,files.jsonanddiff.patchfor this head. - Read the house-rule sections "Readable reviews", "Accuracy and evidence" and "Standard PR response format" from the ruling file.
- Targeted reads at the head, with the reader:
repo_read.py cat core/libs/prx/libSceNgs2.native/tests/Ngs2Custom.cpp 545 560
repo_read.py cat core/libs/prx/libSceNgs2.native/src/Rack.cpp 120 150
repo_read.py search CountedAllocate core/libs/prx/libSceNgs2.native/tests/Ngs2HandleErrors.cpp
repo_read.py search Returned core/libs/prx/libSceNgs2.native/tests/Ngs2HandleErrors.cpp
Results
| Check | Result | Note |
|---|---|---|
| Changed hunks, five files | passed | Each file in the reviewed list was read through its hunks |
| Test helpers used by new rows | passed | Returned and CountedAllocate exist at the head |
| Build and ctest | not run | Author-reported only, not rerun here |
| Negative controls | not run | Author-reported only, not rerun here |
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceNgs2.native/tests/Ngs2HandleErrors.cpp:414: the row "a null free handler and bad option" returns at the option check, before the free-handler throw. The new check atcore/libs/prx/libSceNgs2.native/src/Rack.cpp:294is therefore not exercised by any row, and the row name suggests it is. Add a row with a valid option and a null free handler that expects the throw, or rename the row.
Not verified
- No build or test was run here. The author's ctest result (51/51) and the negative controls are not confirmed by me.
- The error order comes from the prosper permalinks in the description. I did not check them, and the description says the order was not measured on a console.
- The new query
sceNgs2RackQueryBufferSizefor the submixer rack with a null option (inCheckRackCreateArguments) was not checked against the module. The test usesStatusand would fail loudly if the call were refused. Rack.cpp,Ngs2ChannelMixer.cpp,Ngs2Custom.cppandNgs2HandleErrors.cppwere read through their changed hunks and nearby lines, not as whole files.- Linux and macOS were not run. The author ran on Windows only.
To get this to a good state
Nothing is required. The optional point is the non-blocking row above.
What
On
main4b83e9d (these lines are unchanged since e4caa07)sceNgs2RackCreate(core/libs/prx/libSceNgs2.native/src/Rack.cpp:269-279) checks the handle first (:270,0x804A8010), throwsAPS5_INVALID_ARG_EXfor a null buffer info (:271) and returnsSCE_NGS2_ERROR_INVALID_BUFFER_INFO(0x804A8020) only for an unreadable one (:273,ReadGuest, #20893). A buffer info with a nullhost_bufferis not checked: it passes the option check and the system lookup inCreateRack(:141-146), andNgs2Place(core/libs/prx/libSceNgs2.native/src/System.cpp:217-219) throwsstd::invalid_argument.sceNgs2RackCreateWithAllocator(Rack.cpp:281-306) also checks the handle first (:282), throws for a null allocator (:283), returnsSCE_NGS2_ERROR_INVALID_BUFFER_ALLOCATOR(0x804A8023) for an unreadable one (:285) and throws for a nullalloc_handlerorfree_handler(:286).sceNgs2RackCreate(cLV4aiT9JpA, vaddr0xeea0) returns0x804A8020for a null buffer info or host buffer, then0x804A8010for a null handle, then runs the rack core.sceNgs2RackCreateWithAllocator(U546k6orxQo, vaddr0xefc0) returns0x804A8023for a null allocator oralloc_handler, then0x804A8010, then the core. The siblingsceNgs2SystemCreateandsceNgs2SystemCreateWithAllocatoralready do this (System.cpp:382-385,:394-397, fix(libSceNgs2.native): return the module's buffer and allocator errors from sceNgs2SystemCreate and sceNgs2SystemCreateWithAllocator #9316 and fix(libSceNgs2.native): read guest buffer info and allocator through ReadGuest in SystemCreate #20794), with the same constants (core/libs/prx/libSceNgs2.native/include/Ngs2Types.hpp:12-13).sceNgs2SystemCreateandsceNgs2SystemCreateWithAllocatordo.sceNgs2RackCreatereturnsSCE_NGS2_ERROR_INVALID_BUFFER_INFOfor a null buffer info, an unreadable one and a nullhost_buffer, now checked on the local copy; then the null-handle check.sceNgs2RackCreateWithAllocatorreturnsSCE_NGS2_ERROR_INVALID_BUFFER_ALLOCATORfor a null allocator, an unreadable one and a nullalloc_handleron the local copy; then the null-handle check, the option check and the system lookup. The throw for a nullfree_handlerreads the local copy just beforealloc_handleris called (:294-295at 24ee695), so every code the module documents wins over it, asAllocatedoes for the system (System.cpp:233). The option check, the system lookup (0x804A8201) and valid calls are unchanged. Both structs are read once throughReadGuest; no raw guest access is added.main(e4caa07), which contains fix(libSceNgs2.native): read and write rack guest structs through guest copies #20893 and feat(libSceNgs2): check custom submixer rack inputs, ports, matrices and state size at creation #18464. The conflict inRack.cppis resolved as fix(libSceNgs2.native): read and write rack guest structs through guest copies #20893 states: itsReadGuestlines and this pull request's null checks are both kept; inNgs2HandleErrors.cppthe call list ofmainkeeps both sides. Beyond the rule above, one case of fix(libSceNgs2.native): read and write rack guest structs through guest copies #20893 changes: an unreadable buffer info or allocator together with a null handle now returns0x804A8020/0x804A8023instead of0x804A8010, because the copy runs before the handle check as in the system exports; no test covers it. Updated again by mergingmain(4b83e9d), which contains feat(libSceNgs2): implement the ChannelMixer custom module #21478; that merge had no conflicts.CheckRackCreateArgumentsincore/libs/prx/libSceNgs2.native/tests/Ngs2HandleErrors.cpp(:349), afterCheckCreateArguments(:283) and in the same table style, called frommain(:635) next toCheckRackCreateGuestPointers(fix(libSceNgs2.native): read and write rack guest structs through guest copies #20893) andCheckDestroyGuestPointers(fix(libSceNgs2.native): clear the buffer info through guest copies in sceNgs2RackDestroy and sceNgs2SystemDestroy #20970) (:633-634). On a real system, with a submixer rack: a null buffer info and a null host buffer return0x804A8020, also with a null handle and a bad option, and also with an invalid system handle; a valid buffer with a null handle and a bad option returns0x804A8010; a bad option returnsSCE_NGS2_ERROR_INVALID_PEAK_METER_BLOCKS; an invalid system returns0x804A8201. The bad option is a submixer option withnum_peak_meter_blocks = 0, which returns rather than throws. The same rows for the allocator variant, with a null allocator and{nullptr, CountedRelease, 0}, expect0x804A8023;{CountedAllocate, nullptr, 0}with a bad option returnsINVALID_PEAK_METER_BLOCKSand with an invalid system0x804A8201. In every failing row the handle sentinel stays0x5a5aand no allocation is made. Valid arguments create the rack (with the allocator, one allocation), which is destroyed afterwards. fix(libSceNgs2.native): read and write rack guest structs through guest copies #20893's unreadable-pointer rows (:574-584) are unchanged and pass.TestCustomRackChecks(core/libs/prx/libSceNgs2.native/tests/Ngs2Custom.cpp:548) setnum_buffers = 0but passed a null buffer info and requiredstd::invalid_argument, which came from the null buffer. It now passes the realinfoand requiresSCE_NGS2_ERROR_INVALID_NUM_BUFFERSandrack == 0(:690). It passes with and without theRack.cppchange, so it is not a negative control. The file also buildsngs2_core_custom(core/libs/prx/libSceNgs2/CMakeLists.txt).CreateMixerRackincore/libs/prx/libSceNgs2.native/tests/Ngs2ChannelMixer.cpp(:38), added by feat(libSceNgs2): implement the ChannelMixer custom module #21478 after this pull request's last update, passed a zeroNgs2ContextBufferInfo(nullhost_buffer) together with an invalid module option or state size and requiredSCE_NGS2_ERROR_INVALID_OPTION_SIZEandSCE_NGS2_ERROR_INVALID_STATE_SIZE. With this change a nullhost_bufferreturns0x804A8020before the option check, songs2_channelmixerfailed at its line 199 on the merge. The helper now queries the buffer size with the valid variant of the same option (null module option, state size 0) and passes that buffer, asTestCustomRackChecksdoes (Ngs2Custom.cpp:552-558); the expected codes are unchanged. It passes with and without theRack.cppchange, so it is not a negative control. The console runs feat(libSceNgs2): implement the ChannelMixer custom module #21478 cites (#8039) describe nosceNgs2RackCreatecall with a null host buffer, so the order here stays prosper's reading, not measured on a console.docs/dev/debt/changes/fix-libscengs2-rack-create-errors.mdchanges thesceNgs2SystemCreateWithAllocator free handlerentry (docs/dev/debt/libSceNgs2.native.md:85) to namesceNgs2RackCreateandsceNgs2RackCreateWithAllocator: a rack allocator withoutfree_handlerthrows after the option and system checks, and the codes above come from prosper, not measured on a console.std::invalid_argumentfrom portable code on every host; no fault or address is involved, so the negative control fails on Linux too.pr_overlap.py --names sceNgs2RackCreate sceNgs2RackCreateWithAllocatorfinds no other open pull request for the exports.pr_overlap.py --branchreports no shared lines or exports with the open pull requests it can compare (head 24ee695, run on 2026-11-17 against themainof that time); no open pull request it compares changesNgs2ChannelMixer.cpp. It cannot compare feat(ngs2): add experimental I3DL2 reverb #1384 and fix(libSceNgs2.native): write the rack info through guest copies in sceNgs2RackGetInfo #21141, which conflict withmain. Checked by hand: feat(ngs2): add experimental I3DL2 reverb #1384 changes the rack option helpers andCheckedRackOption, and fix(libSceNgs2.native): write the rack info through guest copies in sceNgs2RackGetInfo #21141 (MarcZX10) changessceNgs2RackGetInfo; neither changes the two create exports orNgs2ChannelMixer.cpp, and fix(libSceNgs2.native): write the rack info through guest copies in sceNgs2RackGetInfo #21141 states that its conflicts with this pull request are in different functions and both sides are kept (on 4b83e9d it conflicts withmainand with this branch only inNgs2HandleErrors.cpp). feat(libSceNgs2): add the custom mastering modules 0x17, 0x18 and 0x1a measured on a PS5 #18501, whichpr_overlap.py --branchcompares, also changesRack.cpp, inCheckedRackOption(with a new helper) andRackQueryBufferSize, not the two create exports; it merges cleanly with this branch, and its newNgs2Custom.cpptests create racks with a queried buffer.Tested
Windows 11, WinLibs GCC 15.2.0, Ninja, Release,
BUILD_TESTING=ON, build directory configured through its 8.3 short path, on 24ee695 (the merge commit 45f8a4e withmain4b83e9d, plus the test commit). Built withcmake --build <build> --parallel 10 --target libSceNgs2.native libSceNgs2and the 37ngs2_*_testsexecutables of the build (exit 0);ctest --test-dir <build> -N -R '^ngs2'lists 51 tests. Before every run eachcore/libs/libs/unpatched/*.prxthat also exists in<build>/testswas copied there withcmake -E copy_if_different, and themd5sumoflibSceNgs2.native.prxin both places matched each time.ctest --test-dir <build> -R '^ngs2' --output-on-failurepassed 51/51,ngs2_channelmixer,ngs2_handleerrors,ngs2_custom,ngs2_core_customandngs2_commandsamong them.-R '^ngs2'passed 50/51;ngs2_channelmixerfailed withExit code 0xc0000409andNGS2 check failed at line 199.Rack.cpp: with onlyRack.cppof 4b83e9d put back andlibSceNgs2.native libSceNgs2 ngs2_handleerrors_tests ngs2_channelmixer_tests ngs2_custom_tests ngs2_core_custom_testsrebuilt (exit 0),ctest --test-dir <build> -R '^(ngs2_handleerrors|ngs2_channelmixer|ngs2_custom|ngs2_core_custom)$' --output-on-failurefailedngs2_handleerrorswithsceNgs2RackCreate: invalid argumentand passed the other three, so neither pinned test is a negative control. With the change restored and rebuilt (exit 0),-R '^ngs2'passed 51/51.Ngs2ChannelMixer.cppalone onmain4b83e9d (a second checkout, same host and settings,.prxcopied the same way):ctest --test-dir <build> -R '^ngs2_channelmixer$' --output-on-failurepassed 1/1.python tools/debt_fold.py --checkpasses onmain4b83e9d and on 24ee695, and--show libSceNgs2.nativediffers frommainonly in the changed entry.python tools/check_conventions.py --base upstream/main --head HEADwith this title and description passed.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)