shadps4-emu / shadPS4

PS4 emulator for Windows,Linux,MacOS
https://shadps4.net/
GNU General Public License v2.0
10.76k stars 660 forks source link

Linux - Segmentation fault on latest commit #568

Closed FuzzyWuggzy closed 1 month ago

FuzzyWuggzy commented 2 months ago

Hi ShadPS4 Devs

I just built the latest commit under Fedora 40 following the build instructions in the repo and it just immediately segfaults upon execution, recompiling it with the debug flag and running in gdb prints the following output:

The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/fuzzywuggzy/shadPS4/build/shadps4 ./shadps4 /run/media/fuzzywuggzy/1238389e-7076-449e-bca2-feaa0dbe6dd7/PS4/BREW00082/eboot.bin
Downloading separate debug info for system-supplied DSO at 0x7ffff7fc6000
[Thread debugging using libthread_db enabled]                                                                                                                                                 
Using host libthread_db library "/lib64/libthread_db.so.1".
Downloading separate debug info for /usr/local/cuda-12.0/targets/x86_64-linux/lib/libOpenCL.so.1                                                                                              
[New Thread 0x7fffe30006c0 (LWP 138046)]                                                                                                                                                      
[New Thread 0x7fffe20006c0 (LWP 138047)]

Thread 3 "shadPS4:Log" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe20006c0 (LWP 138047)]
0x00000000004a4671 in Common::Log::PrintColoredMessage(Common::Log::Entry const&) ()

Running the release build (0.2.0) works fine.

It's not much to go on so I don't know if it'll be of any use, but I hope it helps. Thanks for taking the time to give this a look.

lzardy commented 2 months ago

If you have the time, please test a few commits past the 2.0 release commit (da9b26f). You can go back with git reset [commit hash], then rebuild.

FuzzyWuggzy commented 2 months ago

Sorry for the late response, I updated Fedora yesterday and it's having some teething issues, mainly Vulkan related.

I tried compiling the commit you recommended and it suffered the exact same segfault, so I'm thinking there must be something with one of the dependent packages in the Fedora repo, but as the debugging info isn't helpful at all I would't know where to start.

Thank you for responding.

kiwidoggie commented 2 months ago

I am also having similar issues. I am using gcc-14 built from source, on Ubuntu 22.04.4 LTS. I am looking in tracking down the issue, but it could be something with glibc. Not sure if this is 100% related or not, but this is the log I'm getting crashing in a similar location

Loaded '/usr/local/lib64/libstdc++.so.6'. Symbols loaded.
Loaded '/lib/x86_64-linux-gnu/libm.so.6'. Symbols loaded.
Loaded '/usr/local/lib64/libgcc_s.so.1'. Symbols loaded.
Loaded '/lib/x86_64-linux-gnu/libc.so.6'. Symbols loaded.
[New Thread 0x7ffff203e640 (LWP 17983)]

Thread 3 "shadPS4:Log" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff203e640 (LWP 17983)]
std::__new_allocator<char>::allocate (this=0x7ffff203dab0, __n=80) at /usr/local/include/c++/14.2.0/bits/new_allocator.h:151
151        return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp)));
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
Kill the program being debugged? (y or n) [answered Y; input not from terminal]
[Inferior 1 (process 17977) killed]

Looking at the call stack, this is the last shadPS4 location: Common::Log::PrintColoredMessage(Common::Log::Entry const&) ()

NotNite commented 2 months ago

I can get past the colored terminal segfault by checking "Emulate terminal in the output console" in CLion, but then I crash trying to mmap: https://github.com/shadps4-emu/shadPS4/blob/1651db24fe6f972ecad611f4f55404574b68e86c/src/core/address_space.cpp#L311

FuzzyWuggzy commented 2 months ago

663 is able to run the OpenOrbis samples and Sonic Mania on my end, so the issue may be fixed now. @kiwidoggie and @NotNite if you wouldn't mind building it and reporting your experiences that would be great.

Also, this commit manages to show the company logos in The Last Guardian (1.0, 1.3 instantly crashes), so that's progress that has me excited.

awsms commented 1 month ago

Can't even compile it anymore since recent commits,

/home/me/.cache/yay/shadps4-git/src/shadps4/src/core/signals.cpp:62:8: warning: missing terminating " character
   62 | #error "Missing IS_WRITE_ERROR() implementation for target OS and CPU architecture.
      |        ^
[ 72%] Building CXX object CMakeFiles/shadps4.dir/src/core/virtual_memory.cpp.o
[ 73%] Building CXX object CMakeFiles/shadps4.dir/src/core/cpu_patches.cpp.o
[ 73%] Building CXX object CMakeFiles/shadps4.dir/src/shader_recompiler/recompiler.cpp.o
/home/me/.cache/yay/shadps4-git/src/shadps4/src/core/signals.cpp: In constructor ‘Core::SignalDispatch::SignalDispatch()’:
/home/me/.cache/yay/shadps4-git/src/shadps4/src/core/signals.cpp:124:46: error: either all initializer clauses should be designated or none of them should be
  124 |         .sa_flags = SA_SIGINFO | SA_ONSTACK, .sa_sigaction = SignalHandler, .sa_mask = 0,
      |                                              ^
/home/me/.cache/yay/shadps4-git/src/shadps4/src/core/signals.cpp:124:46: error: expected primary-expression before ‘.’ token
/home/me/.cache/yay/shadps4-git/src/shadps4/src/core/signals.cpp: In destructor ‘Core::SignalDispatch::~SignalDispatch()’:
/home/me/.cache/yay/shadps4-git/src/shadps4/src/core/signals.cpp:139:24: error: either all initializer clauses should be designated or none of them should be
  139 |         .sa_flags = 0, .sa_handler = SIG_DFL, .sa_mask = 0,
      |                        ^
/home/me/.cache/yay/shadps4-git/src/shadps4/src/core/signals.cpp:139:24: error: expected primary-expression before ‘.’ token
[ 73%] Building CXX object CMakeFiles/shadps4.dir/src/shader_recompiler/backend/spirv/emit_spirv.cpp.o
make[2]: *** [CMakeFiles/shadps4.dir/build.make:1899: CMakeFiles/shadps4.dir/src/core/signals.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:192: CMakeFiles/shadps4.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...
 -> error making: shadps4-git-exit status 4
 -> Failed to install the following packages. Manual intervention is required:
shadps4-git - exit status 4
squidbus commented 1 month ago

@awsms The fix for that is here https://github.com/shadps4-emu/shadPS4/pull/934

awsms commented 1 month ago

@awsms The fix for that is here #934

Thanks for the heads up! I launched a random game (P.T. CUSA01127) and it crashed immediately,

[Debug] <Critical> signals.cpp:SignalHandler:100: Unreachable code! Unhandled access violation at code address 0x5ec2d7fd8960: Read from address 0x358

Should I open a new bug report, or that seems to be normal? I will retry on wine with a Windows build later on.

awsms commented 1 month ago

can't build since recent commits (haven't checked from exactly which yet):

/home/me/Appz/shadPS4/src/imgui/imgui_config.h:31:100: warning: backslash-newline at end of file
   31 | #define IM_VEC4_CLASS_EXTRA                                                                        \
[ 37%] Building CXX object CMakeFiles/shadps4.dir/src/qt_gui/trophy_viewer.cpp.o
In file included from /usr/include/SDL3/SDL.h:83,
                 from /home/me/Appz/shadPS4/src/imgui/renderer/imgui_impl_sdl3.cpp:10:
/home/me/Appz/shadPS4/src/imgui/renderer/imgui_impl_sdl3.cpp: In function ‘void ImGui::Sdl::UpdateMouseData()’:
/home/me/Appz/shadPS4/src/imgui/renderer/imgui_impl_sdl3.cpp:584:54: error: ‘SDL_TRUE_renamed_true’ was not declared in this scope
  584 |     SDL_CaptureMouse((bd->mouse_buttons_down != 0) ? SDL_TRUE : SDL_FALSE);
      |                                                      ^~~~~~~~
/home/me/Appz/shadPS4/src/imgui/renderer/imgui_impl_sdl3.cpp:584:65: error: ‘SDL_FALSE_renamed_false’ was not declared in this scope
  584 |     SDL_CaptureMouse((bd->mouse_buttons_down != 0) ? SDL_TRUE : SDL_FALSE);
      |                                                                 ^~~~~~~~~
make[2]: *** [CMakeFiles/shadps4.dir/build.make:303: CMakeFiles/shadps4.dir/src/imgui/renderer/imgui_impl_sdl3.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /home/me/Appz/shadPS4/externals/dear_imgui/imgui.h:64,
                 from /home/me/Appz/shadPS4/src/imgui/imgui_texture.h:7,
                 from /home/me/Appz/shadPS4/src/imgui/renderer/texture_manager.h:10,
                 from /home/me/Appz/shadPS4/src/imgui/renderer/texture_manager.cpp:13:
/home/me/Appz/shadPS4/src/imgui/imgui_config.h:31:100: warning: backslash-newline at end of file
   31 | #define IM_VEC4_CLASS_EXTRA                                                                        \
/home/me/Appz/shadPS4/src/qt_gui/cheats_patches.cpp: In lambda function:
/home/me/Appz/shadPS4/src/qt_gui/cheats_patches.cpp:682:46: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated]
  682 |     connect(reply, &QNetworkReply::finished, [=]() {
      |                                              ^
/home/me/Appz/shadPS4/src/qt_gui/cheats_patches.cpp:682:46: note: add explicit ‘this’ or ‘*this’ capture
/home/me/Appz/shadPS4/src/qt_gui/cheats_patches.cpp: In lambda function:
/home/me/Appz/shadPS4/src/qt_gui/cheats_patches.cpp:715:66: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated]
  715 |                     connect(fileReply, &QNetworkReply::finished, [=]() {
      |                                                                  ^
/home/me/Appz/shadPS4/src/qt_gui/cheats_patches.cpp:715:66: note: add explicit ‘this’ or ‘*this’ capture
make[1]: *** [CMakeFiles/Makefile2:228: CMakeFiles/shadps4.dir/all] Error 2
make: *** [Makefile:136: all] Error 2