Repository navigation
fix(libSceNgs2.native): safely probe outputs in sceNgs2RackGetVoiceHandle and sceNgs2CustomRackGetModuleInfo - #20418
Conversation
…ResetOption and sceNgs2SystemQueryBufferSize Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ndle and sceNgs2CustomRackGetModuleInfo Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 6f42c1ccc6:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
ngs2_core_custom_tests,ngs2_custom_tests,ngs2_handleerrors_tests,ngs2_voicehandles_testsbuilt cleanly. - CTest (
ngs2_core_custom_safety_custom_callback,ngs2_core_custom_safety_upstream_callback,ngs2_core_custom_safety_configured_gain,ngs2_core_custom_safety_routing_one_buffer,ngs2_core_custom_safety_routing_two_buffers,ngs2_core_custom,ngs2_custom_safety_custom_callback,ngs2_custom_safety_upstream_callback,ngs2_custom_safety_configured_gain,ngs2_custom_safety_routing_one_buffer,ngs2_custom_safety_routing_two_buffers,ngs2_custom,ngs2_handleerrors,ngs2_voicehandles):4/14 Test #4227: ngs2_core_custom_safety_routing_one_buffer .... Passed 0.27 sec 5/14 Test #4228: ngs2_core_custom_safety_routing_two_buffers ... Passed 0.28 sec 6/14 Test #4236: ngs2_custom_safety_custom_callback ............ Passed 0.24 sec 7/14 Test #4237: ngs2_custom_safety_upstream_callback .......... Passed 0.23 sec 8/14 Test #4238: ngs2_custom_safety_configured_gain ............ Passed 0.22 sec 9/14 Test #4239: ngs2_custom_safety_routing_one_buffer ......... Passed 0.21 sec 10/14 Test #4240: ngs2_custom_safety_routing_two_buffers ........ Passed 0.25 sec 11/14 Test #4235: ngs2_core_custom .............................. Passed 0.69 sec 12/14 Test #4264: ngs2_voicehandles ............................. Passed 0.31 sec 13/14 Test #4263: ngs2_handleerrors ............................. Passed 0.23 sec 14/14 Test #4245: ngs2_custom ................................... Passed 1.77 sec 100% tests passed, 0 tests failed out of 14 - Negative control: with
core/libs/prx/libSceNgs2.native/src/Atrac9.cpp,core/libs/prx/libSceNgs2.native/src/Ngs2Internal.hpp,core/libs/prx/libSceNgs2.native/src/Rack.cpp,core/libs/prx/libSceNgs2.native/src/System.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.8/14 Test #4236: ngs2_custom_safety_custom_callback ............ Passed 0.03 sec 9/14 Test #4238: ngs2_custom_safety_configured_gain ............ Passed 0.02 sec 10/14 Test #4239: ngs2_custom_safety_routing_one_buffer ......... Passed 0.02 sec 11/14 Test #4225: ngs2_core_custom_safety_upstream_callback ..... Passed 0.01 sec 12/14 Test #4264: ngs2_voicehandles .............................***Exception: SegFault 0.58 sec 13/14 Test #4224: ngs2_core_custom_safety_custom_callback ....... Passed 0.02 sec 14/14 Test #4263: ngs2_handleerrors .............................***Exception: SegFault 0.66 sec 71% tests passed, 4 tests failed out of 14 - Code reading:
- Verified in core/libs/prx/libSceNgs2.native/src/Rack.cpp that sceNgs2RackGetVoiceHandle validates the rack handle and voice_id bounds before attempting WriteGuest, ensuring out-of-range voice indices return SCE_NGS2_ERROR_INVALID_VOICE_INDEX (0x804A8305) without probing or mutating the output pointer.
- Verified in core/libs/prx/libSceNgs2.native/src/Rack.cpp that sceNgs2CustomRackGetModuleInfo checks for null output, validates the rack handle, verifies module index bounds and exact info_size before safely writing through WriteGuest, returning SCE_NGS2_ERROR_INVALID_OUT_ADDRESS on unmapped addresses.
- Verified in core/libs/prx/libSceNgs2.native/src/Ngs2Internal.hpp that ReadGuestBytes, WriteGuestBytes, ReadGuest, and WriteGuest preserve errno across copy faults using savedErrno and are correctly declared with inline template linkage.
- Verified in core/libs/prx/libSceNgs2.native/src/Rack.cpp that Ngs2Lock is held across the find, validate, and copy operations in both functions, preventing concurrent modification or destruction races.
- Verified in core/libs/prx/libSceNgs2.native/tests/Ngs2VoiceHandles.cpp and Ngs2Custom.cpp that unit tests exercise unmapped outputs (0x10) against live racks, asserting SCE_NGS2_ERROR_INVALID_OUT_ADDRESS and checking errno preservation (errno == 71).
- Verified in docs/dev/debt/libSceNgs2.native.md that technical debt documentation records the host-safety fallback on unmapped addresses in accordance with repository conventions, with no comments added in source code.
- Minor: please drop the
Generated withfooter from the description; the AI-assisted checkbox can stay.
Looks Good To Me
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. Dropped the footer. I also moved the debt entry into |
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 9efae65c28:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
ngs2_core_custom_tests,ngs2_custom_tests,ngs2_handleerrors_tests,ngs2_voicehandles_testsbuilt cleanly. - CTest (
ngs2_core_custom_safety_custom_callback,ngs2_core_custom_safety_upstream_callback,ngs2_core_custom_safety_configured_gain,ngs2_core_custom_safety_routing_one_buffer,ngs2_core_custom_safety_routing_two_buffers,ngs2_core_custom,ngs2_custom_safety_custom_callback,ngs2_custom_safety_upstream_callback,ngs2_custom_safety_configured_gain,ngs2_custom_safety_routing_one_buffer,ngs2_custom_safety_routing_two_buffers,ngs2_custom,ngs2_handleerrors,ngs2_voicehandles):4/14 Test #4224: ngs2_core_custom_safety_custom_callback ....... Passed 0.04 sec 5/14 Test #4226: ngs2_core_custom_safety_configured_gain ....... Passed 0.05 sec 6/14 Test #4228: ngs2_core_custom_safety_routing_two_buffers ... Passed 0.04 sec 7/14 Test #4225: ngs2_core_custom_safety_upstream_callback ..... Passed 0.03 sec 8/14 Test #4245: ngs2_custom ................................... Passed 0.30 sec 9/14 Test #4239: ngs2_custom_safety_routing_one_buffer ......... Passed 0.04 sec 10/14 Test #4240: ngs2_custom_safety_routing_two_buffers ........ Passed 0.04 sec 11/14 Test #4237: ngs2_custom_safety_upstream_callback .......... Passed 0.03 sec 12/14 Test #4238: ngs2_custom_safety_configured_gain ............ Passed 0.02 sec 13/14 Test #4236: ngs2_custom_safety_custom_callback ............ Passed 0.03 sec 14/14 Test #4264: ngs2_voicehandles ............................. Passed 0.03 sec 100% tests passed, 0 tests failed out of 14 - Negative control: with
core/libs/prx/libSceNgs2.native/src/Atrac9.cpp,core/libs/prx/libSceNgs2.native/src/Ngs2Internal.hpp,core/libs/prx/libSceNgs2.native/src/Rack.cpp,core/libs/prx/libSceNgs2.native/src/System.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.8/14 Test #4224: ngs2_core_custom_safety_custom_callback ....... Passed 0.15 sec 9/14 Test #4225: ngs2_core_custom_safety_upstream_callback ..... Passed 0.15 sec 10/14 Test #4237: ngs2_custom_safety_upstream_callback .......... Passed 0.13 sec 11/14 Test #4236: ngs2_custom_safety_custom_callback ............ Passed 0.14 sec 12/14 Test #4238: ngs2_custom_safety_configured_gain ............ Passed 0.14 sec 13/14 Test #4263: ngs2_handleerrors ............................. Passed 0.14 sec 14/14 Test #4264: ngs2_voicehandles .............................***Exception: SegFault 3.25 sec 79% tests passed, 3 tests failed out of 14 - Code reading:
- core/libs/prx/libSceNgs2.native/src/Rack.cpp: Verified that sceNgs2RackGetVoiceHandle writes voice handles via WriteGuest, returning SCE_NGS2_ERROR_INVALID_OUT_ADDRESS (0x804A8010) on unwritable outputs while maintaining rack handle, null check, and voice index validation precedence.
- core/libs/prx/libSceNgs2.native/src/Rack.cpp: Verified that sceNgs2CustomRackGetModuleInfo writes Ngs2CustomModuleInfo through WriteGuest, returning SCE_NGS2_ERROR_INVALID_OUT_ADDRESS on write failure while maintaining module index and size checks.
- core/libs/prx/libSceNgs2.native/src/Rack.cpp: Verified concurrency and thread safety under Ngs2Lock, ensuring rack lookup and access to rack->voices and rack->customModules remain protected without deadlocks.
- core/libs/prx/libSceNgs2.native/tests/Ngs2VoiceHandles.cpp and Ngs2Custom.cpp: Verified that unit tests test unmapped destination pointer 0x10, assert SCE_NGS2_ERROR_INVALID_OUT_ADDRESS, and confirm caller errno is preserved unchanged.
- AGENTS.md & technical debt: Verified zero code comments were added, and host-safety fallback behavior on unmapped memory is properly documented in docs/dev/debt/changes/fix-ngs2-probe-rack-voice-handle-and-module-info.md.
- Note: the AI-assisted checkbox can stay.
Looks Good To Me
|
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.
|
What
sceNgs2RackGetVoiceHandlestored the voice handle with*handle = ...andsceNgs2CustomRackGetModuleInfocopied the module info with*info = ..., so a non-null output pointing at unmapped memory faulted the host once the rack and index had checked out.Both now write through the guest copy helpers and return
SCE_NGS2_ERROR_INVALID_OUT_ADDRESS(0x804A8010, what each already returns for a null output) when the write fails, witherrnoleft as the caller had it. The rack, voice index, module index and info size checks keep their order, and valid outputs get the same values.Uses the helpers that #20401 (merged) moved into
Ngs2Internal.hpp(independent of #20402). The debt entry, next to the otherRack.cppentry, records the unmapped-memory result as a host-safety fallback; console behaviour there is not measured. It is placed away from the custom-rack entries that #18501 and #18464 edit.Tested
Linux (Ubuntu 26.04.1), GCC 15.2, Release.
ngs2_voicehandles:sceNgs2RackGetVoiceHandleon a live sampler rack with the unmapped output0x10returns0x804A8010and leaveserrnounchanged.ngs2_custom:sceNgs2CustomRackGetModuleInfoon a live custom rack with the unmapped info0x10returns0x804A8010and leaveserrnounchanged; the existing module-info and null-pointer cases still pass.ctest -R '^ngs2_(voicehandles|custom|handleerrors|report|atrac9)$': 5/5 pass.tools/check_conventions.pypasses on the branch and this body.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)