[PR #3978] [MERGED] Kernel.Vmm: Fix potential race condition involving concurrent Allocate and Free calls #3840

Closed
opened 2026-02-27 22:05:10 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/3978
Author: @StevenMiller123
Created: 1/30/2026
Status: Merged
Merged: 1/30/2026
Merged by: @georgemoralis

Base: mainHead: mem-fix-payday2


📝 Commits (2)

  • 66e2c4d Avoid nullptr dereference on GetSocket
  • 875dc0b Lock unmap mutex in PoolExpand and Allocate

📊 Changes

2 files changed (+5 additions, -2 deletions)

View changed files

📝 src/core/file_sys/fs.cpp (+3 -0)
📝 src/core/memory.cpp (+2 -2)

📄 Description

PAYDAY 2 occasionally crashes from a memory assert during dmem Free calls.
This PR makes PoolExpand and Allocate lock the extra "unmap" mutex I added in #3956, which will ensure they don't modify the dmem map after Free searches for areas to unmap.

Not fully sure this fixes the issue, as I can't consistently reproduce this issue, but this is something I should've fixed in that PR in the first place. I'm surprised Unity games didn't reveal this 😅

Also snuck in a fix for sockets, HandleTable::GetSocket would crash if called with an invalid descriptor within the bounds of m_files. Came up while I was making my homebrew, but my socket PR got merged before I could push this fix there.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/3978 **Author:** [@StevenMiller123](https://github.com/StevenMiller123) **Created:** 1/30/2026 **Status:** ✅ Merged **Merged:** 1/30/2026 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `mem-fix-payday2` --- ### 📝 Commits (2) - [`66e2c4d`](https://github.com/shadps4-emu/shadPS4/commit/66e2c4d0482061e8144c9c171125e8ff166213af) Avoid nullptr dereference on GetSocket - [`875dc0b`](https://github.com/shadps4-emu/shadPS4/commit/875dc0bc0a153fd4e3addd8d8aad066cb7adf4eb) Lock unmap mutex in PoolExpand and Allocate ### 📊 Changes **2 files changed** (+5 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/core/file_sys/fs.cpp` (+3 -0) 📝 `src/core/memory.cpp` (+2 -2) </details> ### 📄 Description PAYDAY 2 occasionally crashes from a memory assert during dmem Free calls. This PR makes PoolExpand and Allocate lock the extra "unmap" mutex I added in #3956, which will ensure they don't modify the dmem map after Free searches for areas to unmap. Not fully sure this fixes the issue, as I can't consistently reproduce this issue, but this is something I should've fixed in that PR in the first place. I'm surprised Unity games didn't reveal this 😅 Also snuck in a fix for sockets, HandleTable::GetSocket would crash if called with an invalid descriptor within the bounds of m_files. Came up while I was making my homebrew, but my socket PR got merged before I could push this fix there. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:05:10 +03:00
Sign in to join this conversation.
No milestone
No project
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.

Dependencies

No dependencies set.

Reference
starred/shadPS4#3840
No description provided.