shadps4-emu / shadPS4

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

Linux - memory.cpp:operator assertion failed error #227

Closed gilcel closed 1 month ago

gilcel commented 4 months ago

Hi,

Compiled latest shadPS4 commit 20e83b4 on Linux (OpenSUSE Tumbleweed). User interface works, but trying to launch "OpenOrbis HelloWorld Sample" or "OpenOrbis Graphics Sample" it crashes with:

[Debug] <Critical> memory.cpp:operator():305: Assertion Failed! Adding a mapping to already mapped region

It seems to be a problem with AMD Ryzen 5 5600G (APU) (also same error with AMD Ryzen 3400G) and Mesa 24.1.2 (RADV) driver / Linux Kernel 6.9.7, or Vulkan Version is 1.3.278 (but the one in externals is of version 1.3.288). with clang v18.1.6 / gcc v13.3.0 installed.

shad_log.txt

raphaelthegreat commented 4 months ago

Could you launch it with gdb or any debugger and show a stack trace?

gilcel commented 4 months ago

Ok launched it with gdb ./shadPS4, then launched the Graphics demo:

(gdb)frame

`[Debug] memory.cpp:operator():305: Assertion Failed! Adding a mapping to already mapped region [Thread 0x7fff76e006c0 (LWP 8383) exited]

Thread 1 "shadps4" received signal SIGTRAP, Trace/breakpoint trap. 0x00000000004f0656 in assert_fail_impl() () Missing separate debuginfos, use: zypper install Mesa-dri-debuginfo-24.1.2-1699.386.pm.1.x86_64 Mesa-libEGL1-debuginfo-24.1.2-1699.386.pm.1.x86_64 Mesa-libglapi0-debuginfo-24.1.2-1699.386.pm.1.x86_64 Mesa-vulkan-device-select-debuginfo-24.1.2-1699.386.pm.1.x86_64......` etc....

Shall I install of of these packages ? The list is quite big :-)

raphaelthegreat commented 4 months ago

Not needed. Press bt the moment it crashes to see the stack trace. If it doesn't have any symbols recompile with debug mode (you can do by running cmake --build . --config Debug in build folder)

gilcel commented 4 months ago

(gdb) bt

0 0x00000000004f0656 in assert_fail_impl() ()

1 0x00000000006f1b41 in Core::MemoryManager::AddMapping(unsigned long, unsigned long) ()`

2 0x00000000006f1f46 in Core::MemoryManager::MapMemory(void**, unsigned long, unsigned long,

Core::MemoryProt, Core::MemoryMapFlags, Core::VMAType, std::basic_string_view<char, std::char_traits >, bool, unsigned long, unsigned long) ()

3 0x00000000006f6995 in Core::Module::LoadModuleToMemory(unsigned int&) ()

4 0x00000000006fa3cd in Core::Module::Module(Core::MemoryManager*, std::filesystem::__cxx11::path const&, unsigned int&) ()

5 0x00000000006ecebb in Core::Linker::LoadModule(std::filesystem::__cxx11::path const&, bool) ()

6 0x00000000004dba70 in Core::Emulator::Run(std::filesystem::__cxx11::path const&) ()

7 0x00000000004819ed in MainWindow::CreateConnects()::{lambda()#1}::operator()() const ()

8 0x00007ffff4fe7f90 in ??? () at /lib64/libQt6Core.so.6

9 0x00007ffff66c9652 in QAbstractButton::clicked(bool) () at /lib64/libQt6Widgets.so.6

10 0x00007ffff66c191a in ??? () at /lib64/libQt6Widgets.so.6

11 0x00007ffff66c1bd9 in ??? () at /lib64/libQt6Widgets.so.6

12 0x00007ffff66cd6af in QAbstractButton::mouseReleaseEvent(QMouseEvent*) () at /lib64/libQt6Widgets.so.6

13 0x00007ffff660f344 in QWidget::event(QEvent*) () at /lib64/libQt6Widgets.so.6

14 0x00007ffff65c2f6e in QApplicationPrivate::notify_helper(QObject, QEvent) () at /lib64/libQt6Widgets.so.6

15 0x00007ffff65c6b87 in QApplication::notify(QObject, QEvent) () at /lib64/libQt6Widgets.so.6

16 0x00007ffff4f8ec30 in QCoreApplication::notifyInternal2(QObject, QEvent) () at /lib64/libQt6Core.so.6

17 0x00007ffff65c26f8 in QApplicationPrivate::sendMouseEvent(QWidget, QMouseEvent, QWidget, QWidget, QWidget**, QPointer&, bool, bool) () at /lib64/libQt6Widgets.so.6

18 0x00007ffff6621c77 in ??? () at /lib64/libQt6Widgets.so.6

19 0x00007ffff6624f55 in ??? () at /lib64/libQt6Widgets.so.6

20 0x00007ffff65c2f6e in QApplicationPrivate::notify_helper(QObject, QEvent) () at /lib64/libQt6Widgets.so.6

21 0x00007ffff4f8ec30 in QCoreApplication::notifyInternal2(QObject, QEvent) () at /lib64/libQt6Core.so.6

22 0x00007ffff57ed66b in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () at /lib64/libQt6Gui.so.6

23 0x00007ffff584983c in QWindowSystemInterface::sendWindowSystemEvents(QFlags) () at /lib64/libQt6Gui.so.6

24 0x00007ffff5c0b220 in ??? () at /lib64/libQt6Gui.so.6

25 0x00007ffff5512740 in ??? () at /lib64/libglib-2.0.so.0

26 0x00007ffff5514388 in ??? () at /lib64/libglib-2.0.so.0

27 0x00007ffff5514a3c in g_main_context_iteration () at /lib64/libglib-2.0.so.0

28 0x00007ffff51c1adc in QEventDispatcherGlib::processEvents(QFlags) () at /lib64/libQt6Core.so.6

29 0x00007ffff4f993db in QEventLoop::exec(QFlags) () at /lib64/libQt6Core.so.6

30 0x00007ffff4f92bb6 in QCoreApplication::exec() () at /lib64/libQt6Core.so.6

31 0x00000000004792ba in main ()

raphaelthegreat commented 4 months ago

Try launching emulator standalone without the gui (so CLI)

gilcel commented 4 months ago

Ok need to recompile it then...will do in debug mode

gilcel commented 4 months ago

FYI: When generating cmake build files, it complains with (but build-files are properly written...): -- Could NOT find magic_enum (missing: magic_enum_DIR) -- Could NOT find SDL3 (missing: SDL3_DIR) -- Could NOT find toml11 (missing: toml11_DIR) CMake Warning at CMakeLists.txt:90 (find_package): Could not find a configuration file for package "VulkanHeaders" that is compatible with requested version "1.3.288".

The following configuration files were considered but not accepted:

/usr/share/cmake/VulkanHeaders/VulkanHeadersConfig.cmake, version: 1.3.283

-- Could NOT find VulkanMemoryAllocator (missing: VulkanMemoryAllocator_DIR) -- Could NOT find xbyak (missing: xbyak_DIR) -- Could NOT find xxHash: (Required is at least version "0.8.2") (found ) -- Could NOT find zlib-ng: (Required is at least version "2.1.6") (found ) -- Could NOT find Zydis (missing: Zydis_DIR)

raphaelthegreat commented 4 months ago

If it didn't error out it should be fine. Also consider pinging me on discord as github issues isn't the best medium for support

psucien commented 3 months ago

Is this resolved?

gilcel commented 3 months ago

Unfortunately no...compiled with latest commit 189033a with cmake . --config Debug and now shadPS4 doesn't even display an error message, only "Segmentation fault" with a core dump (compiled and tested with and without GUI)....

With gdb :

(gdb) run $HOME/shadPS4/build/shadps4 $HOME/Downloads/PS4/HelloWorld/eboot.bin

`Starting program: $HOME/shadPS4/build/shadps4 $HOME/shadPS4/build/shadps4 $HOME/Downloads/PS4/HelloWorld/eboot.bin`
[Thread debugging using libthread_db enabled]                                                                                                      
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff0e006c0 (LWP 26095)]
[New Thread 0x7fffefe006c0 (LWP 26096)]
[New Thread 0x7fffef4006c0 (LWP 26097)]

Thread 1 "shadps4" received signal SIGSEGV, Segmentation fault.
0x0000000000522ed4 in Core::AddressSpace::Impl::Impl() ()
(gdb) bt
#0  0x0000000000522ed4 in Core::AddressSpace::Impl::Impl() ()
#1  0x000000000052253e in Core::AddressSpace::AddressSpace() ()
#2  0x000000000068616b in Core::MemoryManager::MemoryManager() ()
#3  0x000000000075f905 in Core::Emulator::Emulator() ()
#4  0x000000000046729a in main ()
ryzendew commented 3 months ago

This also happens on my RTX 3070 on arch linux

gilcel commented 2 months ago

Followup: The Linux shadPS4-v0.20 AppImage works on OpenSUSE Tumbleweed. It runs the OpenOrbis Graphics Sample etc. Compiled latest v.0.2.1-WIP 83bcced and tried to start the Graphics demo: instead of the previous memory.cpp:operator() error it crashes again but with the following error:

(gdb) bt

#0  0x00000000005704a4 in Core::AddressSpace::Impl::Impl (this=0x2675c80) at $HOME/shadPS4-git/src/core/address_space.cpp:319
#1  0x0000000000571570 in std::make_unique<Core::AddressSpace::Impl> () at /usr/include/c++/13/bits/unique_ptr.h:1070
#2  0x000000000056fe08 in Core::AddressSpace::AddressSpace (this=0x275bd90) at $HOME/shadPS4-git/src/core/address_space.cpp:442
#3  0x0000000000756e18 in Core::MemoryManager::MemoryManager (this=0x275bd90) at $HOME/shadPS4-git/src/core/memory.cpp:14
#4  0x00000000004b6d2a in std::make_unique<Core::MemoryManager> () at /usr/include/c++/13/bits/unique_ptr.h:1070
#5  0x00000000004b52c6 in Common::Singleton<Core::MemoryManager>::Instance () at $HOME/shadPS4-git/src/common/singleton.h:15
#6  0x00000000004af783 in Core::Emulator::Emulator (this=0x7fffffffc9e0) at $HOME/shadPS4-git/src/emulator.cpp:67
#7  0x0000000000456c81 in MainWindow::StartGame (this=0x2475b30) at $HOME/shadPS4-git/src/qt_gui/main_window.cpp:424
#8  0x0000000000477ceb in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (MainWindow::*)()>::call(void (MainWindow::*)(), MainWindow*, void**)
    (f=(void (MainWindow::*)(MainWindow * const)) 0x4568f4 <MainWindow::StartGame()>, o=0x2475b30, arg=0x7fffffffcd40) at /usr/include/qt6/QtCore/qobjectdefs_impl.h:145
#9  0x0000000000474fb6 in QtPrivate::FunctionPointer<void (MainWindow::*)()>::call<QtPrivate::List<>, void>(void (MainWindow::*)(), MainWindow*, void**)
    (f=(void (MainWindow::*)(MainWindow * const)) 0x4568f4 <MainWindow::StartGame()>, o=0x2475b30, arg=0x7fffffffcd40) at /usr/include/qt6/QtCore/qobjectdefs_impl.h:182
#10 0x000000000047196b in QtPrivate::QCallableObject<void (MainWindow::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*)
    (which=1, this_=0x27381a0, r=0x2475b30, a=0x7fffffffcd40, ret=0x0) at /usr/include/qt6/QtCore/qobjectdefs_impl.h:553
#11 0x00007ffff53e7f90 in ??? () at /lib64/libQt6Core.so.6
...

(gdb) frame

#0  0x00000000005704a4 in Core::AddressSpace::Impl::Impl (this=0x2675c80) at $HOME/shadPS4-git/src/core/address_space.cpp:319
319             reinterpret_cast<u8*>(mmap(reinterpret_cast<void*>(SYSTEM_MANAGED_MIN), virtual_size,
(gdb) exit

Increasing max_map_count didn't change anything=> vm.max_map_count=524288 in /etc/sysctl.conf

gilcel commented 1 month ago

This issue can be closed, since launching the demos works now! But I didn't investigate which commit fixed it (I was away for one week and recompiled with latest code 1b12138 today and launched the demos: it just works :-) Thanks for all your effort.