xiota / dolphin-primehack

Dolphin fork intended to give Metroid Prime Trilogy mouselook controls
Other
2 stars 0 forks source link

Primehack crashes when adding a default path #1

Closed hikagura99 closed 1 week ago

hikagura99 commented 2 months ago

Whenever i try to add a default rom path to the list, it crashes and when relaunched it didn't save the setting. This happens only on primehack, standard dolphin is not having any problem. This happens both when adding it with a double click from the starting screen and when adding it from the configuration settings. It crashes only after it has been selected, not before or after opening the file explorer. I'm running it on an HP 255 G8 with Arch Linux, Zen Kernel 6.9.7 with KDE Plasma 6 on a Wayland Session as a DE (obviously with the QT_QPA_PLATFORM=xcb environment variable)

Neryss commented 1 month ago

Same crash, it also happens when trying to open the rom directly from the "open" menu. free(): invalid pointer

Trying to run the ROM directly without the GUI leads to a segfault: QT_QPA_PLATFORM=xcb primehack -e /nvme1/roms/wii/Metroid\ Prime\ Trilogy\ \(Europe\)\ \(En,Fr,De,Es,It\). -b

I can load the ROM correctly on vanilla "dolphin-emu-git".

Ferdi265 commented 1 week ago

I'm experiencing the same crash as well, but the crash goes away when commenting out the : ${_build_clang:=true} line in the PKGBUILD. This seems to be a miscompilation or ABI issue when compiling with clang if most of the rest of the system is compiled with GCC, but I haven't investigated it thoroughly.

xiota commented 1 week ago

Sorry for my late response. I wasn't receiving notifications for this repo.

Does the problem still occur with recent package update (1.1.4.r10.g9650329)?

Ferdi265 commented 1 week ago

Doesn't crash any more on latest patch from my testing, with both GCC and Clang.

EDIT: Still crashes with Clang when starting the Metroid Prime 3 RVZ (loading core dump right now to give a backtrace)

Ferdi265 commented 1 week ago

Crash (when loading Metroid Prime 3 PAL RVZ):

free(): invalid pointer
Aborted (core dumped)

Backtrace:

pwndbg> bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007c5b508a5463 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:78
#2  0x00007c5b5084c120 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007c5b508334c3 in __GI_abort () at abort.c:79
#4  0x00007c5b50834354 in __libc_message_impl (fmt=fmt@entry=0x7c5b509c22f5 "%s\n") at ../sysdeps/posix/libc_fatal.c:132
#5  0x00007c5b508af765 in malloc_printerr (str=str@entry=0x7c5b509c0082 "free(): invalid pointer") at malloc.c:5772
#6  0x00007c5b508b1c4c in _int_free (av=<optimized out>, p=p@entry=0x6411e2c04610, have_lock=have_lock@entry=0) at malloc.c:4507
#7  0x00007c5b508b45ce in __GI___libc_free (mem=0x6411e2c04620) at malloc.c:3398
#8  0x00006411dd91fdae in std::__new_allocator<unsigned char>::deallocate (__p=0x6411e2c04620 "", this=<optimized out>, __n=<optimized out>)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/new_allocator.h:172
#9  std::allocator<unsigned char>::deallocate (__p=0x6411e2c04620 "", this=<optimized out>, __n=<optimized out>)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/allocator.h:208
#10 std::allocator_traits<std::allocator<unsigned char> >::deallocate (__p=0x6411e2c04620 "", __a=<optimized out>, __n=<optimized out>)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/alloc_traits.h:513
#11 std::vector<unsigned char, std::allocator<unsigned char> >::_M_default_append(unsigned long)::_Guard::~_Guard() (this=<optimized out>)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/vector.tcc:852
#12 std::vector<unsigned char, std::allocator<unsigned char> >::_M_default_append (this=0x6411e2c25568, __n=4)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/vector.tcc:904
#13 0x00006411ddcfe6b9 in std::vector<unsigned char, std::allocator<unsigned char> >::resize (this=0x6411e2c25568, __new_size=4)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/stl_vector.h:1016
#14 DiscIO::RVZPackDecompressor::Decompress (this=0x6411e2c25550, in=..., out=0x6411e1a1dd90, in_bytes_read=0x6411e1a1ddb0)
    at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DiscIO/WIACompression.cpp:336
#15 0x00006411ddcf274d in DiscIO::WIARVZFileReader<true>::Chunk::Read (this=0x6411e1a1dd70, offset=0, size=4, out_ptr=0x7ffeb1618920 "")
    at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DiscIO/WIABlob.cpp:715
#16 0x00006411ddcf1bd5 in DiscIO::WIARVZFileReader<true>::ReadFromGroups
    (this=0x6411e1a1dd30, offset=<optimized out>, size=<optimized out>, out_ptr=<optimized out>, chunk_size=<optimized out>, sector_size=<optimized out>, data_offset=<optimized out>, data_size=<optimized out>, group_index=<optimized out>, number_of_groups=<optimized out>, exception_lists=<optimized out>)
    at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DiscIO/WIABlob.cpp:543
#17 0x00006411ddcf13d2 in DiscIO::WIARVZFileReader<true>::Read (this=0x6411e1a1dd30, offset=<optimized out>, size=<optimized out>, out_ptr=<optimized out>)
    at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DiscIO/WIABlob.cpp:404
#18 0x00006411ddcce257 in DiscIO::BlobReader::ReadSwapped<unsigned int> (this=0x34220, offset=213536)
    at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DiscIO/Blob.h:85
#19 DiscIO::VolumeWii::VolumeWii (this=0x6411e3045790, reader=std::unique_ptr<DiscIO::BlobReader> = {...})
    at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DiscIO/VolumeWii.cpp:53
#20 std::make_unique<DiscIO::VolumeWii, std::unique_ptr<DiscIO::BlobReader, std::default_delete<DiscIO::BlobReader> > > (__args=<optimized out>)
    at /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/unique_ptr.h:1076
#21 DiscIO::TryCreateDisc (reader=<optimized out>) at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DiscIO/Volume.cpp:93
#22 0x00006411dd9192a6 in DiscIO::CreateDisc (reader=std::unique_ptr<DiscIO::BlobReader> = {...})
    at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DiscIO/Volume.cpp:104
#23 DiscIO::CreateDisc (path="/home/yrlf/Roms/MetroidPrime3.rvz")
    at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DiscIO/Volume.cpp:109
#24 BootParameters::GenerateFromFile (paths=std::vector of length -3438374431695, capacity -3438374431695 = {...}, boot_session_data_=...)
    at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/Core/Boot/Boot.cpp:240
#25 0x00006411dd84ddce in MainWindow::StartGame (this=0x7ffeb161aa00, paths=<optimized out>, boot_session_data=std::unique_ptr<BootSessionData> = {...})
    at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DolphinQt/MainWindow.cpp:1133
#26 0x00006411dd84d988 in MainWindow::ScanForSecondDiscAndStartGame
    (this=0x7ffeb161aa00, game=..., boot_session_data=std::unique_ptr<BootSessionData> = {...})
    at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DolphinQt/MainWindow.cpp:1104
#27 MainWindow::StartGame
    (this=0x7ffeb161aa00, path="/home/yrlf/Roms/MetroidPrime3.rvz", scan=<optimized out>, boot_session_data=std::unique_ptr<BootSessionData> = {...})
    at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DolphinQt/MainWindow.cpp:1121
#28 0x00006411dd851dab in MainWindow::Play (this=<optimized out>, savestate_path=<optimized out>)
    at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DolphinQt/MainWindow.cpp:873
#29 0x00006411dd859034 in MainWindow::ConnectGameList()::$_0::operator()() const (this=<optimized out>)
    at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DolphinQt/MainWindow.cpp:732
#30 QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, MainWindow::ConnectGameList()::$_0>::call(MainWindow::ConnectGameList()::$_0&, void**) (f=<optimized out>, arg=<optimized out>) at /usr/include/qt6/QtCore/qobjectdefs_impl.h:137
#31 QtPrivate::FunctorCallable<MainWindow::ConnectGameList()::$_0>::call<QtPrivate::List<>, void>(MainWindow::ConnectGameList()::$_0&, void*, void**)
    (f=<optimized out>, arg=<optimized out>) at /usr/include/qt6/QtCore/qobjectdefs_impl.h:345
#32 QtPrivate::QCallableObject<MainWindow::ConnectGameList()::$_0, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*)
    (which=<optimized out>, this_=<optimized out>, r=<optimized out>, a=<optimized out>, ret=<optimized out>)
    at /usr/include/qt6/QtCore/qobjectdefs_impl.h:555
#33 0x00007c5b5bfa3397 in QtPrivate::QSlotObjectBase::call
    (this=0x6411e21f2b90, r=0x7ffeb161aa00, a=0x7ffeb1619338, this=<optimized out>, r=<optimized out>, a=<optimized out>)
    at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qobjectdefs_impl.h:469
#34 doActivate<false> (sender=<optimized out>, signal_index=<optimized out>, argv=<optimized out>)
    at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qobject.cpp:4086
#35 0x00007c5b5bfa3397 in QtPrivate::QSlotObjectBase::call
    (this=0x6411e02ef790, r=0x6411e08c0df0, a=0x7ffeb1619520, this=<optimized out>, r=<optimized out>, a=<optimized out>)
    at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qobjectdefs_impl.h:469
#36 doActivate<false> (sender=<optimized out>, signal_index=<optimized out>, argv=<optimized out>)
    at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qobject.cpp:4086
#37 0x00007c5b5d3e1b4f in QAbstractItemView::doubleClicked (this=0x6411e08dd3b0, _t1=...)
    at /usr/src/debug/qt6-base/build/src/widgets/Widgets_autogen/include/moc_qabstractitemview.cpp:687
#38 QAbstractItemView::mouseDoubleClickEvent (this=0x6411e08dd3b0, event=0x7ffeb1619b80)
    at /usr/src/debug/qt6-base/qtbase/src/widgets/itemviews/qabstractitemview.cpp:2022
#39 0x00007c5b5d14d0a3 in QWidget::event (this=0x6411e08dd3b0, event=0x7ffeb1619b80) at /usr/src/debug/qt6-base/qtbase/src/widgets/kernel/qwidget.cpp:9029
#40 0x00007c5b5d1e4a78 in QFrame::event (this=0x6411e08dd3b0, e=0x7ffeb1619b80) at /usr/src/debug/qt6-base/qtbase/src/widgets/widgets/qframe.cpp:521
#41 0x00007c5b5bf44ef8 in QCoreApplicationPrivate::sendThroughObjectEventFilters (receiver=receiver@entry=0x6411e0b8e890, event=event@entry=0x7ffeb1619b80)
    at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qcoreapplication.cpp:1281
#42 0x00007c5b5d0fc8bc in QApplicationPrivate::notify_helper (this=this@entry=0x6411e0111910, receiver=receiver@entry=0x6411e0b8e890, e=e@entry=0x7ffeb1619b80) at /usr/src/debug/qt6-base/qtbase/src/widgets/kernel/qapplication.cpp:3281
#43 0x00007c5b5d101e59 in QApplication::notify (this=<optimized out>, receiver=<optimized out>, e=0x7ffeb1619b80) at /usr/src/debug/qt6-base/qtbase/src/widgets/kernel/qapplication.cpp:2765
#44 0x00007c5b5bf45aa8 in QCoreApplication::notifyInternal2 (receiver=0x6411e0b8e890, event=0x7ffeb1619b80) at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qcoreapplication.cpp:1142
#45 0x00007c5b5bf45afd in QCoreApplication::sendSpontaneousEvent (receiver=<optimized out>, event=<optimized out>) at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qcoreapplication.cpp:1597
#46 0x00007c5b5d0f3f9d in QApplicationPrivate::sendMouseEvent (receiver=0x6411e0b8e890, event=0x7ffeb1619b80, alienWidget=<optimized out>, nativeWidget=0x7ffeb161aa00, buttonDown=<optimized out>, lastMouseReceiver=..., spontaneous=true, onlyDispatchEnterLeave=false)
    at /usr/src/debug/qt6-base/qtbase/src/widgets/kernel/qapplication.cpp:2347
#47 0x00007c5b5d1635c2 in QWidgetWindow::handleMouseEvent (this=0x6411e03d3bc0, event=event@entry=0x7ffeb161a020) at /usr/src/debug/qt6-base/qtbase/src/widgets/kernel/qwidgetwindow.cpp:649
#48 0x00007c5b5d164c20 in QWidgetWindow::event (this=0x6411e03d3bc0, event=0x7ffeb161a020) at /usr/src/debug/qt6-base/qtbase/src/widgets/kernel/qwidgetwindow.cpp:263
#49 0x00007c5b5d0fc8cc in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x6411e03d3bc0, e=0x7ffeb161a020) at /usr/src/debug/qt6-base/qtbase/src/widgets/kernel/qapplication.cpp:3287
#50 0x00007c5b5bf45aa8 in QCoreApplication::notifyInternal2 (receiver=0x6411e03d3bc0, event=0x7ffeb161a020) at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qcoreapplication.cpp:1142
#51 0x00007c5b5bf45afd in QCoreApplication::sendSpontaneousEvent (receiver=<optimized out>, event=<optimized out>) at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qcoreapplication.cpp:1597
#52 0x00007c5b5c7780ec in QGuiApplicationPrivate::processMouseEvent (e=0x6411e02eb810) at /usr/src/debug/qt6-base/qtbase/src/gui/kernel/qguiapplication.cpp:2367
#53 0x00007c5b5c7e7724 in QWindowSystemInterface::sendWindowSystemEvents (flags=flags@entry=...) at /usr/src/debug/qt6-base/qtbase/src/gui/kernel/qwindowsysteminterface.cpp:1114
#54 0x00007c5b3f7c6b87 in xcbSourceDispatch (source=<optimized out>) at /usr/src/debug/qt6-base/qtbase/src/plugins/platforms/xcb/qxcbeventdispatcher.cpp:57
#55 0x00007c5b50d0eab9 in g_main_dispatch (context=0x7c5b38000f00) at ../glib/glib/gmain.c:3344
#56 0x00007c5b50d709e7 in g_main_context_dispatch_unlocked (context=0x7c5b38000f00) at ../glib/glib/gmain.c:4152
#57 g_main_context_iterate_unlocked.isra.0 (context=context@entry=0x7c5b38000f00, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/glib/gmain.c:4217
#58 0x00007c5b50d0dfc5 in g_main_context_iteration (context=0x7c5b38000f00, may_block=1) at ../glib/glib/gmain.c:4282
#59 0x00007c5b5c1a82bd in QEventDispatcherGlib::processEvents (this=0x6411e02a6d20, flags=...) at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qeventdispatcher_glib.cpp:394
#60 0x00007c5b5bf4ff66 in QEventLoop::processEvents (this=0x7ffeb161a440, flags=...) at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qeventloop.cpp:100
#61 QEventLoop::exec (this=0x7ffeb161a440, flags=...) at /usr/src/debug/qt6-base/qtbase/src/corelib/kernel/qeventloop.cpp:182
#62 0x00007c5b5bf4a11d in QCoreApplication::exec () at /usr/src/debug/qt6-base/qtbase/src/corelib/global/qflags.h:74
#63 0x00006411dd837d60 in main (argc=<optimized out>, argv=0x7ffeb161bb58) at /usr/src/debug/dolphin-emu-primehack-git/xiota.primehack/Source/Core/DolphinQt/Main.cpp:309
#64 0x00007c5b50834e08 in __libc_start_call_main (main=main@entry=0x6411dd82e430 <main(int, char**)>, argc=argc@entry=1, argv=argv@entry=0x7ffeb161bb58) at ../sysdeps/nptl/libc_start_call_main.h:58
#65 0x00007c5b50834ecc in __libc_start_main_impl (main=0x6411dd82e430 <main(int, char**)>, argc=1, argv=0x7ffeb161bb58, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffeb161bb48) at ../csu/libc-start.c:360
#66 0x00006411dd5ee2e5 in _start ()

Last line in the dolphin codebase was Source/Core/DiscIO/WIACompression.cpp:336, m_decompressed.data.resize(sizeof(u32));.

xiota commented 1 week ago

I've switched the primehack package to build with GCC to prevent the crash.

The file Source/Core/DiscIO/WIACompression.cpp is not altered by the primehack patches, so I suspect an upstream issue. Would you mind building and testing aur/dolphin-emu-debugfast-git? It has variable to enable building with clang.

Ferdi265 commented 1 week ago

I've switched the primehack package to build with GCC to prevent the crash.

The file Source/Core/DiscIO/WIACompression.cpp is not altered by the primehack patches, so I suspect an upstream issue. Would you mind building and testing aur/dolphin-emu-debugfast-git? It has variable to enable building with clang.

I just quickly checked quickly because I was in the middle of playing, but didn't have time for a thorough investigation, but will see if upstream has a similar issue later and will report my findings here and/or upstream respectively.

xiota commented 1 week ago

Completely understandable... lots of playing to catch up on because of my delayed response. Please let me know if upstream is affected so I can decide whether this issue should be closed.

Ferdi265 commented 1 week ago

Completely understandable... lots of playing to catch up on because of my delayed response. Please let me know if upstream is affected so I can decide whether this issue should be closed.

The crash also happens when checking out upstream dolphin in dolphin-primehack's PKGBUILD instead of the primehack branch. I also enabled address sanitizer in a separate run, which produced this:

/home/yrlf/.cache/yay/dolphin-emu-primehack-git/src/xiota.primehack/Source/Core/DiscIO/WIABlob.cpp:768:17: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/string.h:44:28: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/yrlf/.cache/yay/dolphin-emu-primehack-git/src/xiota.primehack/Source/Core/DiscIO/WIABlob.cpp:768:17 

It appears Clang is optimizing more aggressively in the presence of undefined behaviour, which breaks the build with clang. Will report this upstream and possibly fix this.

Ferdi265 commented 1 week ago

See linked upstream PR.

Ferdi265 commented 1 week ago

Completely understandable... lots of playing to catch up on because of my delayed response. Please let me know if upstream is affected so I can decide whether this issue should be closed.

The crash also happens when checking out upstream dolphin in dolphin-primehack's PKGBUILD instead of the primehack branch. I also enabled address sanitizer in a separate run, which produced this:

/home/yrlf/.cache/yay/dolphin-emu-primehack-git/src/xiota.primehack/Source/Core/DiscIO/WIABlob.cpp:768:17: runtime error: null pointer passed as argument 1, which is declared to never be null
/usr/include/string.h:44:28: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/yrlf/.cache/yay/dolphin-emu-primehack-git/src/xiota.primehack/Source/Core/DiscIO/WIABlob.cpp:768:17 

It appears Clang is optimizing more aggressively in the presence of undefined behaviour, which breaks the build with clang. Will report this upstream and possibly fix this.

There were more UBsan messages than this, but those did not lead to crashes, but should probably also be fixed.

xiota commented 1 week ago

There were more UBsan messages ... should probably also be fixed.

Thanks for looking into it. I guess see what upstream prefers before doing too much.

Suppose they accept your PR. Do you think the AUR package default should go back to clang or stick with gcc?

Ferdi265 commented 1 week ago

There were more UBsan messages ... should probably also be fixed.

Thanks for looking into it. I guess see what upstream prefers before doing too much.

Suppose they accept your PR. Do you think the AUR package default should go back to clang or stick with gcc?

Dolphin built with GCC seems to be much better tested than Clang. The dolphin CI uses GCC and AFAIK almost all distros and the flatpak also build with GCC. For users a default of GCC would probably be better.

xiota commented 1 week ago

Should be fixed by 6245dcd57d3cb78aa1d9fdbf53832716478396ca. Thank you @Ferdi265