Repository navigation
fix(libSceNgs2.native): write the voice state through guest copies in sceNgs2VoiceGetState - #20941
Merged
oneandonlydean merged 10 commits intoNov 15, 2026
Conversation
…est in sceNgs2VoiceGetState For a sampler voice, sceNgs2VoiceGetState built the state directly in the guest output through its pointer, so an unmapped output faulted the host part way through. The state is now built in a local Ngs2SamplerVoiceState and written once: the common part for the PS4 common-only size, the whole struct otherwise. An unwritable output returns SCE_NGS2_ERROR_INVALID_OUT_ADDRESS, the code the rest of this function uses for outputs. Writable output receives the same bytes as before.
…ceNgs2VoiceGetState An unwritable output of the full sampler state size must return SCE_NGS2_ERROR_INVALID_OUT_ADDRESS and keep errno. The common-only size applies to the PS4 library only and is not covered here.
…st in sceNgs2VoiceGetState For a reverb voice, sceNgs2VoiceGetState cleared the guest output and set its flags through the pointer, so an unmapped output faulted the host. The state is now built in a local Ngs2VoiceState and written with WriteGuest. An unwritable output returns SCE_NGS2_ERROR_INVALID_OUT_ADDRESS. Writable output receives the same bytes as before.
…eNgs2VoiceGetState An unwritable output for a reverb voice must return SCE_NGS2_ERROR_INVALID_OUT_ADDRESS.
…h WriteGuest in sceNgs2VoiceGetState For a custom mastering voice, sceNgs2VoiceGetState cleared the guest output and set its flags through the pointer, so an unmapped output faulted the host. The state is now built in a local Ngs2VoiceState and written with WriteGuest. An unwritable output returns SCE_NGS2_ERROR_INVALID_OUT_ADDRESS. Writable output receives the same bytes as before.
…tate An unwritable output for a custom mastering voice must return SCE_NGS2_ERROR_INVALID_OUT_ADDRESS.
…uest in sceNgs2VoiceGetState For a submixer voice, sceNgs2VoiceGetState built the state directly in the guest output through its pointer, so an unmapped output faulted the host. The state is now built in a local Ngs2SubmixerVoiceState and written with WriteGuestBytes. An unwritable output returns SCE_NGS2_ERROR_INVALID_OUT_ADDRESS. Writable output receives the same bytes as before.
…sceNgs2VoiceGetState An unwritable output for a submixer voice must return SCE_NGS2_ERROR_INVALID_OUT_ADDRESS.
…WriteGuestBytes in sceNgs2VoiceGetState For a custom sampler voice, sceNgs2VoiceGetState built the state directly in the guest output through its pointer, so an unmapped output faulted the host. The state is now built in a local Ngs2CustomSamplerVoiceState and written once with WriteGuestBytes. The branches keep their previous results: a pending play reports only the in-use flag, and an idle voice without a render reports its flags with no decoded count. An unwritable output returns SCE_NGS2_ERROR_INVALID_OUT_ADDRESS.
…te in sceNgs2VoiceGetState The custom sampler voice helper of the filter test now checks that an unwritable output returns SCE_NGS2_ERROR_INVALID_OUT_ADDRESS, before it returns the voice. The check has no effect on the voice.
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
sceNgs2VoiceGetStatebuilt the voice state directly in the guest output, through the caller's pointer, for each rack type. An unmapped output faulted the host part way through the write.For each rack type (sampler, reverb, submixer, custom mastering and custom sampler), the state is now built in a local struct and written once with
WriteGuestorWriteGuestBytes.Ngs2SamplerVoiceStateotherwise, as before.SCE_NGS2_ERROR_INVALID_OUT_ADDRESS, the code the rest of this function already uses for outputs. Writable output receives the same bytes as before.Commits: one
fixand onetestper rack type, ten in total. Eachfixand eachtestbuilds and passes on its own. The tests are added to the existing voice-handle, filter and custom-rack test files.No external source is needed: the change only copies the state, and the error code is the one this function already returns for its other outputs.
Tested
Host: Linux, kernel 6.1, x86_64. Throwaway archive build of the tree, with the CPU startup gate patched in that build only (no change to HostCpu.cpp in this branch).
3a826f1fcf, onupstream/mainc53d8bb2d7: all 49ngs2_*tests Passed (35 test executables built).ngs2_voicehandles,ngs2_filterandngs2_customtests run on their own; all pass.upstream/main'sVoice.cppand this branch's tests,ngs2_voicehandlesstops with SIGSEGV at address0x40, inside the write of the unwritable sampler state (the test passes the address0x10).PS4_LIBRARYis set, and the test binaries here do not take it, so it is not exercised by these tests.pr_overlap.pyfailed closed:sceNgs2VoiceGetState(it writes its state withstd::memseton the guest pointer) and adds a test toNgs2Custom.cpp. The custom mastering block will conflict textually. The resolution is to keep its peak-meter logic and write its state through a local buffer ofstate_sizebytes withWriteGuestBytes. Its new test is in a different part ofNgs2Custom.cppfrom the line this PR adds.mainalready has that case label, so that change is written against an older base and will not compile after a merge as it stands; it is not a conflict this PR creates.Voice.cppandNgs2Custom.cpp; the lines they change are not the ones this PR changes.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)