[GH-ISSUE #337] Crash (SIGFPE) in MemoryManager::SearchFree() #50

Closed
opened 2026-02-27 21:04:19 +03:00 by kerem · 3 comments
Owner

Originally created by @tkoecker on GitHub (Jul 29, 2024).
Original GitHub issue: https://github.com/shadps4-emu/shadPS4/issues/337

I've encountered a crash in MemoryManager::SearchFree() where the function was called with the default value of alignment (which is 0). The crash happens inside the

virtual_addr = Common::AlignUp(vma.base, alignment);

where the value % size with size of 0 triggers a SIGFPE.

I guess this can be fixed by calling Common::AlignUp the same way as in the other calls in this class:

virtual_addr = alignment > 0 ? Common::AlignUp(vma.base, alignment) : vma.base;

(or maybe by defaulting alignment to 1 instead - not sure what the semantic of aligning to 0 bytes should be)

Originally created by @tkoecker on GitHub (Jul 29, 2024). Original GitHub issue: https://github.com/shadps4-emu/shadPS4/issues/337 I've encountered a crash in `MemoryManager::SearchFree()` where the function was called with the default value of `alignment` (which is `0`). The crash happens inside the ``` virtual_addr = Common::AlignUp(vma.base, alignment); ``` where the `value % size` with `size` of `0` triggers a `SIGFPE`. I guess this can be fixed by calling `Common::AlignUp` the same way as in the other calls in this class: ``` virtual_addr = alignment > 0 ? Common::AlignUp(vma.base, alignment) : vma.base; ``` (or maybe by defaulting alignment to `1` instead - not sure what the semantic of aligning to `0` bytes should be)
kerem closed this issue 2026-02-27 21:04:19 +03:00
Author
Owner

@georgemoralis commented on GitHub (Jul 29, 2024):

can you test https://github.com/shadps4-emu/shadPS4/pull/338 . Should fix the issue

<!-- gh-comment-id:2255637397 --> @georgemoralis commented on GitHub (Jul 29, 2024): can you test https://github.com/shadps4-emu/shadPS4/pull/338 . Should fix the issue
Author
Owner

@tkoecker commented on GitHub (Jul 29, 2024):

Thx. Yes this fixes the issue. The execution progresses further now.

<!-- gh-comment-id:2255658082 --> @tkoecker commented on GitHub (Jul 29, 2024): Thx. Yes this fixes the issue. The execution progresses further now.
Author
Owner

@georgemoralis commented on GitHub (Jul 29, 2024):

ok fine :)

<!-- gh-comment-id:2255697026 --> @georgemoralis commented on GitHub (Jul 29, 2024): ok fine :)
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#50
No description provided.