Implement Missing NGS2 System Functions Lock & Unlock #1542
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1542
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1542/head"
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?
@MrBigBritches on GitHub · 2026-10-15 22:48 UTC · original
MrBigBritches:mbbr-ngs2-system-locking→main· +44 −8 · 3 files · 5 commits · merged 2026-10-15 23:39 UTCGame: Trails in the Sky 1st Chapter
Problem: The game is able to run without these fixes, but the console output regularly complained about 2 missing functions:
gThZqM5PYlQandJXRC5n0RQls. These functions correlate to locking and unlocking the NGS mutex.Fix: Implemented both functions loosely based off the existing code available from the AnyPS5 repository^1.
Testing:
Before

After

AI use: None
1 - core/libs/prx/libSceNgs2.native/src/System.cpp#L225-L237
@coderabbitai[bot] on GitHub · 2026-10-15 22:50 UTC · original · edited 2026-10-15 23:11 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
60bc2a04-2fea-478a-9419-72606671a275📥 Commits
Reviewing files that changed from the base of the PR and between
194c4a8355and8fb7afe4fa.📒 Files selected for processing: 1
src/libs/ngs2.cpp🚧 Files skipped from review as they are similar to previous changes: 1
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
📝 Walkthrough
The change adds public
Ngs2SystemLockandNgs2SystemUnlockAPIs. Each returnsNGS2_ERROR_INVALID_SYSTEM_HANDLEif the handle is zero or its cast pointer is null. Otherwise, each locks or unlocks the mutex of the referenced system. NGS2 initialization registers both APIs.Priority: ➖ Normal
Change: Bug fix
Merge Risk: 🔵 Low · up to
8fb7aThe new lock and unlock functions fix the missing-function reports. A guest that passes a garbage nonzero system handle could still crash the emulator. Normal games pass valid handles, so the risk is small and bounded, but adding a handle membership check would remove it.
Pre-merge checks:
4 ·
1
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-10-15 22:50 UTC · original · edited 2026-10-15 23:39 UTC
On
src/libs/ngs2.cppline 2643 (outdated):🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Validate system handles before accessing the mutex.
A nonzero invalid
system_handlepasses this check.ngs->mutex.Lock()then accesses an invalid address and can crash the emulator. The unlock function has the same fault at Line 2654. Check handle membership before dereferencing it, asNgs2SystemGetInfodoes at Lines 1124–1131.✅ Addressed in commit
1d21428@coderabbitai[bot] on GitHub · 2026-10-15 22:50 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
2692fa06-9288-4e1d-ab53-a25bedec929e📥 Commits
Reviewing files that changed from the base of the PR and between
9e41d8320aand3d49d79251.📒 Files selected for processing: 3
src/libs/libAudio.cppsrc/libs/ngs2.cppsrc/libs/ngs2.hIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@coderabbitai[bot] on GitHub · 2026-10-15 23:07 UTC · original · edited 2026-10-15 23:11 UTC
On
src/libs/ngs2.cppline 2642 (outdated):🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Return the invalid-handle error for zero handles.
EXIT_NOT_IMPLEMENTED(system_handle == 0)runs before the null check in both APIs. The project handler requests emergency shutdown and exits, so handle0never returnsNGS2_ERROR_INVALID_SYSTEM_HANDLE. Return that error from the zero-handle branch instead. The NGS2 reference APIs return the invalid-system-handle error for unrecognized handles. (raw.githubusercontent.com)Also applies to: 2655-2655
✅ Addressed in commit
8fb7afe@coderabbitai[bot] on GitHub · 2026-10-15 23:07 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
52b54925-d102-44ae-a63d-3b5edf9e0a43📥 Commits
Reviewing files that changed from the base of the PR and between
3d49d79251and194c4a8355.📒 Files selected for processing: 1
src/libs/ngs2.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.