[GH-ISSUE #1582] [Debug] <Critical> scalar_memory.cpp: unreachable code #540

Closed
opened 2026-02-27 21:06:47 +03:00 by kerem · 8 comments
Owner

Originally created by @gandalth on GitHub (Nov 23, 2024).
Original GitHub issue: https://github.com/shadps4-emu/shadPS4/issues/1582

Originally assigned to: @polybiusproxy on GitHub.

CUSA16194 DIRT 5: shadps4 crashes on startup with this debug information:

[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:405: Compiling cs shader 0xf69de71c
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:405: Compiling cs shader 0x394fe8e8
[Core] stubs.cpp:CommonStub:42: Stub: scePthreadSetaffinity (nid: bt3CTBKmGyI) called, returning zero to 0x90068ae09
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:405: Compiling cs shader 0x385a8cf7
[Render.Vulkan] vk_pipeline_cache.cpp:CompileModule:405: Compiling cs shader 0x385a8cf7

[Debug] <Critical> scalar_memory.cpp:operator():49: Unreachable code!
Trace/breakpoint trap

Originally created by @gandalth on GitHub (Nov 23, 2024). Original GitHub issue: https://github.com/shadps4-emu/shadPS4/issues/1582 Originally assigned to: @polybiusproxy on GitHub. CUSA16194 DIRT 5: shadps4 crashes on startup with this debug information: [Render.Vulkan] <Info> vk_pipeline_cache.cpp:CompileModule:405: Compiling cs shader 0xf69de71c [Render.Vulkan] <Info> vk_pipeline_cache.cpp:CompileModule:405: Compiling cs shader 0x394fe8e8 [Core] <Error> stubs.cpp:CommonStub:42: Stub: scePthreadSetaffinity (nid: bt3CTBKmGyI) called, returning zero to 0x90068ae09 [Render.Vulkan] <Info> vk_pipeline_cache.cpp:CompileModule:405: Compiling cs shader 0x385a8cf7 [Render.Vulkan] <Info> vk_pipeline_cache.cpp:CompileModule:405: Compiling cs shader 0x385a8cf7 [Debug] \<Critical\> scalar_memory.cpp:operator():49: Unreachable code! Trace/breakpoint trap
kerem closed this issue 2026-02-27 21:06:47 +03:00
Author
Owner

@polybiusproxy commented on GitHub (Nov 23, 2024):

https://github.com/shadps4-emu/shadPS4/blob/main/src/shader_recompiler/frontend/translate/scalar_memory.cpp#L41
Can you debug what is smrd at the time of the unreachable?

<!-- gh-comment-id:2495419920 --> @polybiusproxy commented on GitHub (Nov 23, 2024): https://github.com/shadps4-emu/shadPS4/blob/main/src/shader_recompiler/frontend/translate/scalar_memory.cpp#L41 Can you debug what is `smrd` at the time of the unreachable?
Author
Owner

@gandalth commented on GitHub (Nov 23, 2024):

Sure, happy to help!

Would I have to recompile in order to do that? My current build (on Linux Debian Testing) has been compiled like this:

cmake .. -DCMAKE_C_COMPILER=clang-19 -DCMAKE_CXX_COMPILER=clang++-19 -DENABLE_DISCORD_RPC=OFF -DENABLE_QT_GUI=ON

Can I use gdb to debug or do you recommend something else?

<!-- gh-comment-id:2495422187 --> @gandalth commented on GitHub (Nov 23, 2024): Sure, happy to help! Would I have to recompile in order to do that? My current build (on Linux Debian Testing) has been compiled like this: cmake .. -DCMAKE_C_COMPILER=clang-19 -DCMAKE_CXX_COMPILER=clang++-19 -DENABLE_DISCORD_RPC=OFF -DENABLE_QT_GUI=ON Can I use gdb to debug or do you recommend something else?
Author
Owner

@polybiusproxy commented on GitHub (Nov 23, 2024):

I'm not quite knowledgeable about Linux, but I'd recommend setting up Visual Studio Code and GDB to make debugging (and most things over all) easier

<!-- gh-comment-id:2495429216 --> @polybiusproxy commented on GitHub (Nov 23, 2024): I'm not quite knowledgeable about Linux, but I'd recommend setting up Visual Studio Code and GDB to make debugging (and most things over all) easier
Author
Owner

@gandalth commented on GitHub (Nov 23, 2024):

I recompiled with -DCMAKE_BUILD_TYPE=DEBUG and used ddd/gdb to add a breakpoint.

In ddd, shadps4 receives a SEGFAULT in GAME_MainThread before I reach the UNREACHABLE().
The last smrd I see before that (but does not lead to the UNREACHABLE()) has offset=0, imm=1, count=8.

<!-- gh-comment-id:2495440788 --> @gandalth commented on GitHub (Nov 23, 2024): I recompiled with -DCMAKE_BUILD_TYPE=DEBUG and used ddd/gdb to add a breakpoint. In ddd, shadps4 receives a SEGFAULT in GAME_MainThread before I reach the UNREACHABLE(). The last smrd I see before that (but does not lead to the UNREACHABLE()) has offset=0, imm=1, count=8.
Author
Owner

@polybiusproxy commented on GitHub (Nov 23, 2024):

That one looks correct, but I'm interested in the one that leads to the UNREACHABLE()

<!-- gh-comment-id:2495450542 --> @polybiusproxy commented on GitHub (Nov 23, 2024): That one looks correct, but I'm interested in the one that leads to the UNREACHABLE()
Author
Owner

@gandalth commented on GitHub (Nov 23, 2024):

This one leads to UNREACHABLE():

smrd.offset = 1
smrd.imm = 0
smrd.count = 4

SQ_SRC_LITERAL = 255

<!-- gh-comment-id:2495474334 --> @gandalth commented on GitHub (Nov 23, 2024): This one leads to UNREACHABLE(): smrd.offset = 1 smrd.imm = 0 smrd.count = 4 SQ_SRC_LITERAL = 255
Author
Owner

@gandalth commented on GitHub (Nov 27, 2024):

@polybiusproxy : can I help more in finding how we got into the incorrect smrd?
I can easily add more debug output in my local copy.

<!-- gh-comment-id:2502960960 --> @gandalth commented on GitHub (Nov 27, 2024): @polybiusproxy : can I help more in finding how we got into the incorrect smrd? I can easily add more debug output in my local copy.
Author
Owner

@Hermiten commented on GitHub (Feb 12, 2025):

Hello, I'm closing this one, this is now tagged with a label and also present in the wiki:
https://github.com/shadps4-emu/shadPS4/wiki/III.-Guide-of%EF%BC%9CCritical%EF%BC%9Elog

Thanks you

<!-- gh-comment-id:2654556427 --> @Hermiten commented on GitHub (Feb 12, 2025): Hello, I'm closing this one, this is now tagged with a label and also present in the wiki: https://github.com/shadps4-emu/shadPS4/wiki/III.-Guide-of%EF%BC%9CCritical%EF%BC%9Elog Thanks you
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#540
No description provided.