Fix crash on Mac and Android caused by a buffer validation error fix in #92 #105

Merged
Ghost merged 15 commits from AsperTheDog/Ryubing:fix-vertex-crash-mvk into master 2026-05-18 16:34:05 +00:00
Contributor

This PR fixes a bug introduced in #92. In that PR, the problematic commit did its work directly on the updater's own arrays, calling Auto.Get() on each entry as it went, and nulling entries out along the way. The problem is that Get() can call back into Commit (via ClearMirrors -> Rebind), and when it did, that reentrant Commit would read from the same arrays the outer call was still in the middle of processing, hit one of the entries the outer had already nulled, and throw an NullReferenceException. The fix is to have Commit start by copying everything it needs into local variables and resetting _count to zero, so a reentrant call sees a clean updater and operates on its own data. The outer call then writes its snapshot back into the native arrays just before recording the Vulkan bind.

This PR fixes a bug introduced in #92. In that PR, the problematic commit did its work directly on the updater's own arrays, calling Auto.Get() on each entry as it went, and nulling entries out along the way. The problem is that Get() can call back into Commit (via ClearMirrors -> Rebind), and when it did, that reentrant Commit would read from the same arrays the outer call was still in the middle of processing, hit one of the entries the outer had already nulled, and throw an NullReferenceException. The fix is to have Commit start by copying everything it needs into local variables and resetting _count to zero, so a reentrant call sees a clean updater and operates on its own data. The outer call then writes its snapshot back into the native arrays just before recording the Vulkan bind.
Add shader non-uniform indexing support
Some checks failed
Pull Request Triage / triage (pull_request_target) Successful in 13s
Build PR / linux-arm64 (Release) (pull_request) Has been cancelled
Build PR / linux-x64 (Release) (pull_request) Has been cancelled
Build PR / win-x64 (Release) (pull_request) Has been cancelled
Build PR / macOS Universal (Release) (pull_request) Has been cancelled
bd6b0dc7b8
Merge pull request 'Input: Implement HD Rumble for compatible Nin devices (#40)' (#1) from projects/Ryubing:master into master
All checks were successful
Build PR / linux-arm64 (Release) (pull_request) Successful in 4m43s
Build PR / linux-x64 (Release) (pull_request) Successful in 8m37s
Build PR / win-x64 (Release) (pull_request) Successful in 8m15s
Build PR / macOS Universal (Release) (pull_request) Successful in 7m16s
d2291fcac8
Reviewed-on: AsperTheDog/Ryubing#1
Add shader non-uniform indexing support
Some checks failed
Build PR / linux-x64 (Release) (pull_request) Failing after 1m47s
Build PR / win-x64 (Release) (pull_request) Failing after 1m48s
Build PR / macOS Universal (Release) (pull_request) Has been cancelled
Build PR / linux-arm64 (Release) (pull_request) Has been cancelled
7bb6df9ade
Reviewed-on: AsperTheDog/Ryubing#2
Reviewed-on: #96
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [SharpCompress](https://github.com/adamhathcock/sharpcompress) | `0.48.0` → `0.48.1` | ![age](https://developer.mend.io/api/mc/badges/age/nuget/SharpCompress/0.48.1?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/SharpCompress/0.48.0/0.48.1?slim=true) |

---

### Release Notes

<details>
<summary>adamhathcock/sharpcompress (SharpCompress)</summary>

### [`v0.48.1`](https://github.com/adamhathcock/sharpcompress/releases/tag/0.48.1): - GZip writing fix

[Compare Source](https://github.com/adamhathcock/sharpcompress/compare/0.48.0...0.48.1)

#### What's Changed

- release test cleanup by [@&#8203;adamhathcock](https://github.com/adamhathcock) in [#&#8203;1322](https://github.com/adamhathcock/sharpcompress/pull/1322)
- Fix GZip write async by [@&#8203;adamhathcock](https://github.com/adamhathcock) in [#&#8203;1320](https://github.com/adamhathcock/sharpcompress/pull/1320)

**Full Changelog**: <https://github.com/adamhathcock/sharpcompress/compare/0.48.0...0.48.1>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNzguMCIsInVwZGF0ZWRJblZlciI6IjQzLjE3OC4wIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->

Reviewed-on: #97
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [Sep](https://github.com/nietras/Sep) | `0.13.0` → `0.14.1` | ![age](https://developer.mend.io/api/mc/badges/age/nuget/Sep/0.14.1?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/Sep/0.13.0/0.14.1?slim=true) |

---

### Release Notes

<details>
<summary>nietras/Sep (Sep)</summary>

### [`v0.14.1`](https://github.com/nietras/Sep/releases/tag/v0.14.1): 0.14.1

#### What's Changed

- Improve SepReaderOptions.Unescape/.Trim comments by [@&#8203;nietras](https://github.com/nietras) in [#&#8203;542](https://github.com/nietras/Sep/pull/542)
- Improve SepReader/WriterExtensions.Strict() comments by [@&#8203;nietras](https://github.com/nietras) in [#&#8203;543](https://github.com/nietras/Sep/pull/543)

**Full Changelog**: <https://github.com/nietras/Sep/compare/v0.14.0...v0.14.1>

### [`v0.14.0`](https://github.com/nietras/Sep/releases/tag/v0.14.0): 0.14.0

#### What's Changed

- Add `leaveOpen` overloads for SepReaderOptions.From\* via SepTextReaderDisposers by [@&#8203;Copilot](https://github.com/Copilot) in [#&#8203;530](https://github.com/nietras/Sep/pull/530)
- Bump MSTest from 4.2.1 to 4.2.2 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;533](https://github.com/nietras/Sep/pull/533)
- Bump github/codeql-action from 4.35.2 to 4.35.3 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;532](https://github.com/nietras/Sep/pull/532)
- Bump step-security/harden-runner from 2.19.0 to 2.19.1 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;531](https://github.com/nietras/Sep/pull/531)
- Confirm statuses:write is the correct minimum permission for super-linter (not checks:write) by [@&#8203;Copilot](https://github.com/Copilot) in [#&#8203;540](https://github.com/nietras/Sep/pull/540)

**Full Changelog**: <https://github.com/nietras/Sep/compare/v0.13.0...v0.14.0>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNzguMCIsInVwZGF0ZWRJblZlciI6IjQzLjE3OC4wIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->

Reviewed-on: #98
The previous fix for Tomodachi Life (#91) included the extension to all shaders, independently on if it was needed or not. This PR fixes that by lazily adding the extension only when it is actually needed.

This change should not be noticed by anyone, but it avoids having to modify shaders that do not perform any type of dynamic indexing, which apparently is something some modders care about.

Co-authored-by: AsperTheDog <guillerman0000@gmail.com>
Reviewed-on: #99
This PR fixes several validation errors caused by invalid Vulkan usage. These validation errors often end up invoking Undefined Behavior on the driver side, which can lead to artifacts or crashes which are driver specific and otherwise incredibly hard to track. I don't think it should have any impact on performance, but it would be good to test it with as many games as possible (maybe a bug in a game was fixed?).

Each commit fixes an error. I added to each a description with the validation error that was fixed and a small explanation on what was causing it and how I fixed it.

Co-authored-by: AsperTheDog <guillerman0000@gmail.com>
Reviewed-on: #92
This PR adresses the following issue : `ProcessLoader.ActiveApplication` could return invalid results when `_latestPid` pointed to a process that no longer existed in the kernel's process table. The original exception path was commented out and bypassed (by sh0inx?) with `GetValueOrDefault` to prevent UI lockups, but this only resolved the symptoms without fixing the root cause.

This was due to sevral factors :
- `_latestPid` was never reset or validated against the actual process state
- ProcessLoader maintained its own `_processesByPid` dictionary separate from the kernel's `KernelContext.Processes`
- No cleanups happened when processes exited or were terminated
- ProcessLoader state could drift out of sync with the kernel process table

**Solution/Fixes**
- Validate` _latestPid` against the kernel process table before returning `ActiveApplication`
- Check process state (Exited/Exiting) and automatically clear stale references
- Add thread-safe cleanup methods (`ClearProcess`, `ClearAllProcesses`)
- Integrate `ClearAllProcesses` into Switch.Dispose for proper shutdown cleanup
- Add warning logs when stale PID is detected and cleared for debugging

**Code Changes**:
- `ProcessLoader.cs`: Add `_pidLock`, update `ActiveApplication` with validation, add cleanup methods
- `Switch.cs`: Call `Processes.ClearAllProcesses()` in Dispose()

Reviewed-on: #102
French translations + capital letters on spanish translations

Reviewed-on: #101
WIP: Potential fix. Needs testing
Some checks failed
Pull Request Triage / triage (pull_request_target) Successful in 43s
Build PR / macOS Universal (Release) (pull_request) Has been cancelled
Build PR / linux-x64 (Release) (pull_request) Has been cancelled
Build PR / win-x64 (Release) (pull_request) Has been cancelled
Build PR / linux-arm64 (Release) (pull_request) Successful in 4m26s
081ca1c340
|E| GUI.RenderThread Application : Unhandled exception caught: System.NullReferenceException: Object reference not set to an instance of an object.
   at Ryujinx.Graphics.Vulkan.VertexBufferUpdater.Commit(CommandBufferScoped cbs) in /workspace/projects/Ryubing/src/Ryujinx.Graphics.Vulkan/VertexBufferUpdater.cs:line 66
   at Ryujinx.Graphics.Vulkan.PipelineBase.Rebind(Auto`1 buffer, Int32 offset, Int32 size) in /workspace/projects/Ryubing/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs:line 701
   at Ryujinx.Graphics.Vulkan.VertexBufferUpdater.Commit(CommandBufferScoped cbs) in /workspace/projects/Ryubing/src/Ryujinx.Graphics.Vulkan/VertexBufferUpdater.cs:line 66
   at Ryujinx.Graphics.Vulkan.PipelineBase.RecreateGraphicsPipelineIfNeeded() in /workspace/projects/Ryubing/src/Ryujinx.Graphics.Vulkan/PipelineBase.cs:line 1652
   at Ryujinx.Graphics.GAL.Multithreading.CommandHelper.<>c.<InitLookup>b__5_1[T](Span`1 memory, ThreadedRenderer threaded, IRenderer renderer) in /workspace/projects/Ryubing/src/Ryujinx.Graphics.GAL/Multithreading/CommandHelper.cs:line 43
   at Ryujinx.Graphics.GAL.Multithreading.ThreadedRenderer.RenderLoop() in /workspace/projects/Ryubing/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs:line 146
   at Ryujinx.Graphics.GAL.Multithreading.ThreadedRenderer.RunLoop(ThreadStart gpuLoop) in /workspace/projects/Ryubing/src/Ryujinx.Graphics.GAL/Multithreading/ThreadedRenderer.cs:line 115
   at Ryujinx.Ava.Systems.AppHost.RenderLoop() in /workspace/projects/Ryubing/src/Ryujinx/Systems/AppHost.cs:line 1096
   at System.Threading.Thread.StartCallback()
AsperTheDog closed this pull request 2026-05-18 12:22:23 +00:00
AsperTheDog reopened this pull request 2026-05-18 12:24:51 +00:00
Reviewed-on: AsperTheDog/Ryubing#4
Merge branch 'master' into fix-vertex-crash-mvk
All checks were successful
Build PR / linux-x64 (Release) (pull_request) Successful in 8m0s
Build PR / win-x64 (Release) (pull_request) Successful in 8m1s
Build PR / macOS Universal (Release) (pull_request) Successful in 8m11s
Build PR / linux-arm64 (Release) (pull_request) Successful in 8m53s
02e9a88cfa
Ghost merged commit b7772462f1 into master 2026-05-18 16:34:05 +00:00
Ghost deleted branch fix-vertex-crash-mvk 2026-05-18 16:34:05 +00:00
Ghost added this to the 1.4.0 milestone 2026-06-27 17:15:48 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
projects/Ryubing!105
No description provided.