Repository navigation
fix(libSceNgs2.native): read the waveform format and write the block and frame outputs through the guest helpers - #20158
Merged
oneandonlydean merged 1 commit intoNov 14, 2026
Conversation
…and frame outputs through the guest helpers
PrivacyOnion
approved these changes
Nov 14, 2026
PrivacyOnion
left a comment
Contributor
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 079c02946d:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
ngs2_parse_testsbuilt cleanly. - CTest (
ngs2_parse):1/1 Test #4199: ngs2_parse ....................... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 - Negative control: with
core/libs/prx/libSceNgs2.native/src/Atrac9.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/1 Test #4199: ngs2_parse .......................***Exception: SegFault 0.13 sec 0% tests passed, 1 tests failed out of 1 - Code reading:
- core/libs/prx/libSceNgs2.native/src/Atrac9.cpp: Verified sceNgs2CalcWaveformBlock checks block == nullptr before reading the format via ReadGuest, initializes and populates local block data (retaining zeroed output on format error), and writes output via WriteGuest while returning SCE_NGS2_ERROR_INVALID_OUT_ADDRESS on write failure.
- core/libs/prx/libSceNgs2.native/src/Atrac9.cpp: Verified sceNgs2GetWaveformFrameInfo preserves null-pointer validation order, reads format through ReadGuest, enforces channel and sample-rate boundaries, and writes out_frame_size, out_num_frame_samples, out_units_per_frame, and out_num_delay_samples via WriteGuest returning SCE_NGS2_ERROR_INVALID_OUT_ADDRESS on unmapped addresses.
- core/libs/prx/libSceNgs2.native/src/Atrac9.cpp: Verified ReadGuest and WriteGuest helper templates properly preserve and restore thread-local errno across GuestCopyIn_nid_no_patch and GuestCopyOut_nid_no_patch invocations.
- core/libs/prx/libSceNgs2.native/tests/Ngs2Parse.cpp: Verified TestCalcWaveformBlockGuestErrors and TestFrameInfoGuestErrors exercise unmapped guest pointer inputs (0x10) across all input and output positions and assert that errno remains unaffected.
- docs/dev/debt/libSceNgs2.native.md: Verified the fallback behavior on unmapped memory is properly documented under the technical debt ledger with accurate relative markdown links.
- AGENTS.md compliance: Verified zero disallowed comments were introduced in the implementation or test files, no temporary or extraneous files were created, and Conventional Commit guidelines are satisfied.
- 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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
sceNgs2CalcWaveformBlockandsceNgs2GetWaveformFrameInfoincore/libs/prx/libSceNgs2.native/src/Atrac9.cppdereferenced both the guest-suppliedNgs2WaveformFormatand their guest output pointers directly, so an unmapped guest address crashed the host instead of returning an error.GuestCopyIn_nid_no_patchand the block (Ngs2WaveformBlock) or the four frame outputs are built locally and written throughGuestCopyOut_nid_no_patch; the caller'serrnois preserved across both helpers.INVALID_WAVEFORM_FORMATwhen the format cannot be read,INVALID_OUT_ADDRESSwhen the block or an output cannot be written, and the previous return values (including the zeroed block written before an invalid-format error) are unchanged.docs/dev/debt/libSceNgs2.native.mdrecords the fallback as unmeasured on a console (490-character bullet).Tested
cmake -S . -B build-libs -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ONsucceeded;cmake --build build-libs --target ngs2_parse_testsbuilt 263 targets with no diagnostics from the changed file.ctest --test-dir build-libs -R '^ngs2_(parse|atrac9)$':100% tests passed, 0 tests failed out of 2(ngs2_parse0.01 s,ngs2_atrac9).Atrac9.cppfrommainand the newNgs2Parse.cpp,ctest -R '^ngs2_parse$'fails with1 tests failed out of 1/ngs2_parse (SEGFAULT)— the new cases pass only with the change.errnochecked to stay at the value the caller set.python3 tools/check_conventions.py --base origin/main:All conventions checks passed.Gate 1 (
tools/pr_overlap.py --branch contrib/ngs2-waveform-guest-pointers --jobs 8) failed closed on PR #5548, which conflicts withmainindocs/dev/debt/libSceNgs2.native.mdonly. No open PR touchesAtrac9.cpporNgs2Parse.cpp: the file lists of the open PRs whose title mentions ngs2 (#5548, #1384, #13491, #15946, #17913, #18464, #18501, #19444) nameExport.cpp,Rack.cpp,Custom.cpp,Reverb.cpp,Ngs2Internal.hpp, the other test files and the debt file, never the two files this PR changes. The overlap is the debt bullet appended at the end of that file.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)