[PR #3418] [MERGED] Memory: Align size and address in posix_munmap #3450

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

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/3418
Author: @StevenMiller123
Created: 8/15/2025
Status: Merged
Merged: 8/15/2025
Merged by: @georgemoralis

Base: mainHead: munmap-fix


📝 Commits (3)

  • c190c69 Properly align address and size in munmap
  • b8a02ef Format len and phys_addr in mmap
  • 1f1b742 Update memory.cpp

📊 Changes

2 files changed (+6 additions, -3 deletions)

View changed files

📝 src/core/libraries/kernel/memory.cpp (+4 -3)
📝 src/core/memory.cpp (+2 -0)

📄 Description

From looking at the FreeBSD source code, munmap aligns down the address, and aligns up the size (like what's done for mprotect).

Fixing this resolves the a case of the following unreachable, which was encountered by War Thunder (CUSA00224) because we aligned size during a file mmap, but didn't perform the same alignment for the unmap.

[Debug] <Critical> address_space.cpp:234 EnsureSplitRegionForMapping: Unreachable code!
Region splitting failed: The parameter is incorrect.

CUSA00224 Main.log
CUSA00224 PR.log

I've also added parameter formatting to posix_mmap logging, since it's the only memory function where we didn't have any formatting for length, phys_addr, flags, or prot values.


🔄 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/3418 **Author:** [@StevenMiller123](https://github.com/StevenMiller123) **Created:** 8/15/2025 **Status:** ✅ Merged **Merged:** 8/15/2025 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `munmap-fix` --- ### 📝 Commits (3) - [`c190c69`](https://github.com/shadps4-emu/shadPS4/commit/c190c69f5016e8a384543a23b301476ae984bdb4) Properly align address and size in munmap - [`b8a02ef`](https://github.com/shadps4-emu/shadPS4/commit/b8a02ef68c6dc8319c908f8fafff5b54cb13a43b) Format len and phys_addr in mmap - [`1f1b742`](https://github.com/shadps4-emu/shadPS4/commit/1f1b74215115cdf605dacb4e5e341acbe4d602d0) Update memory.cpp ### 📊 Changes **2 files changed** (+6 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/core/libraries/kernel/memory.cpp` (+4 -3) 📝 `src/core/memory.cpp` (+2 -0) </details> ### 📄 Description From looking at the FreeBSD source code, munmap aligns down the address, and aligns up the size (like what's done for mprotect). Fixing this resolves the a case of the following unreachable, which was encountered by War Thunder (CUSA00224) because we aligned size during a file mmap, but didn't perform the same alignment for the unmap. ``` [Debug] <Critical> address_space.cpp:234 EnsureSplitRegionForMapping: Unreachable code! Region splitting failed: The parameter is incorrect. ``` [CUSA00224 Main.log](https://github.com/user-attachments/files/21781880/CUSA00224.Main.log) [CUSA00224 PR.log](https://github.com/user-attachments/files/21781881/CUSA00224.PR.log) I've also added parameter formatting to `posix_mmap` logging, since it's the only memory function where we didn't have any formatting for length, phys_addr, flags, or prot values. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:03:44 +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#3450
No description provided.