mamedev / mame

MAME
https://www.mamedev.org/
Other
8.03k stars 2k forks source link

Qt debugger crashes on hard reset #9789

Closed Abystus closed 2 years ago

Abystus commented 2 years ago

Description:

When loading a rom through the debugger in Linux the emulator will crash with a Segmentation fault (core dumped) error. Even if you choose the Cancel option when opening a rom the emulator will crash. This happens with many different systems, but the easiest one to test is the NES. These same steps work correctly on Windows.

Steps to Reproduce:

  1. Open MAME with the debug option enabled
  2. Type NES and open the Nintendo Entertainment System
  3. Open [Use File Manager]
  4. When the debugger shows up, choose Images > Nes Cartridge Slot > Mount
  5. Choose your rom and then choose Open (Alternatively, you can press Cancel to also see the crash.)

Expected Behavior:

MAME will load the game without crashing, and you should then be able to hit (Run) F5 to start emulation.

System Info:

MAME Version: 0.243 Operating System: Kubuntu 21.10 KDE Plasma Version: 5.22.5 KDE Frameworks Version: 5.86.0 Qt Version: 5.15.2 Kernel Version: 5.13.0-41-generic (64-bit) Graphics Platform: X11 Processors: 12 × AMD Ryzen 5 5600G with Radeon Graphics Memory: 16.0 GiB of RAM Graphics Processor: Radeon RX 5500 (Mesa Driver)

Video:

https://user-images.githubusercontent.com/1529049/169629331-78d9ee4b-101b-47b2-9cdc-746bb02554e2.mp4

cuavas commented 2 years ago

It’s not specific to Linux – it affects the Qt debugger on Windows as well (it doesn’t affect the Win32 debugger). It seems to be specific to “reset on load” media devices, i.e. those that can contain additional hardware and hence require a hard reset to switch media.

But you don’t need to use the media menu in the debugger at all – you just need to cause a hard reset. You can do it by hitting F5 in the debugger to continue, switching to the main MAME window, and pressing Shift-F3 to hard reset, or even more easily just by choosing Hard Reset from the Debug menu in the debugger.

Sample stack trace:

#0  0x00007ff7cc9ba988 in debug_view::set_visible_size(debug_view_xy) ()
#1  0x00007ff7cff936c7 in DebuggerView::paintEvent(QPaintEvent*) ()
#2  0x00007ff8618373b8 in QWidget::event(QEvent*) ()
   from msys64\mingw64\bin\Qt5Widgets.dll
#3  0x00007ff8618de974 in QFrame::event(QEvent*) ()
   from msys64\mingw64\bin\Qt5Widgets.dll
#4  0x00007ff862653bdc in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) [clone .part.0] ()
   from msys64\mingw64\bin\Qt5Core.dll
#5  0x00007ff8617f7fc2 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from msys64\mingw64\bin\Qt5Widgets.dll
#6  0x00007ff8626553d0 in QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*) ()
   from msys64\mingw64\bin\Qt5Core.dll
#7  0x00007ff86182fefb in QWidgetPrivate::sendPaintEvent(QRegion const&) ()
   from msys64\mingw64\bin\Qt5Widgets.dll
#8  0x00007ff86183032f in QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, QFlags<QWidgetPrivate::DrawWidgetFlag>, QPainter*, QWidgetRepaintManager*) ()
   from msys64\mingw64\bin\Qt5Widgets.dll
#9  0x00007ff861807ca6 in QWidgetRepaintManager::paintAndFlush() ()
   from msys64\mingw64\bin\Qt5Widgets.dll
#10 0x00007ff861837cc8 in QWidget::event(QEvent*) ()
   from msys64\mingw64\bin\Qt5Widgets.dll
#11 0x00007ff8617f7fd3 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from msys64\mingw64\bin\Qt5Widgets.dll
#12 0x00007ff862654aca in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
   from msys64\mingw64\bin\Qt5Core.dll
#13 0x00007ff86265b119 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
   from msys64\mingw64\bin\Qt5Core.dll
#14 0x00007ff8680e195e in QWindowsGuiEventDispatcher::sendPostedEvents() ()
   from msys64\mingw64\share\qt5\plugins\platforms\qwindows.dll
#15 0x00007ff8626b128f in QEventDispatcherWin32::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from msys64\mingw64\bin\Qt5Core.dll
#16 0x00007ff8680e1945 in QWindowsGuiEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from msys64\mingw64\share\qt5\plugins\platforms\qwindows.dll
#17 0x00007ff862654f98 in QCoreApplication::processEvents(QFlags<QEventLoop::ProcessEventsFlag>, int) ()
   from msys64\mingw64\bin\Qt5Core.dll
#18 0x00007ff7cc89015c in video_manager::frame_update(bool) ()
#19 0x00007ff7cc84adb5 in mame_machine_manager::create_ui(running_machine&) ()
#20 0x00007ff7c8eb19b4 in running_machine::start() ()
#21 0x00007ff7c8eb34e6 in running_machine::run(bool) ()
#22 0x00007ff7cc85080b in mame_machine_manager::execute() ()
#23 0x00007ff7cf27e719 in cli_frontend::start_execution(mame_machine_manager*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) ()
#24 0x00007ff7cf27eccd in cli_frontend::execute(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&) ()
#25 0x00007ff7cc84b449 in emulator_info::start_frontend(emu_options&, osd_interface&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&) ()
#26 0x00007ff7cf2a87bf in SDL_main ()
#27 0x00007ff7cc856f7a in main_getcmdline ()
#28 0x00007ff7c39c13b1 in __tmainCRTStartup ()
    at C:/_/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:321
#29 0x00007ff7c39c14e6 in mainCRTStartup ()
    at C:/_/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:202
Abystus commented 2 years ago

@cuavas any update on a fix soon (seems to still be present in the latest build)? Figured I would check back after a few months had passed :).

cuavas commented 2 years ago

I haven’t been working on it. I just investigated it a bit to narrow down what was going on so when someone wants to fix it they’ve got a bit more to work with.

Abystus commented 2 years ago

@ajrhacker Would you mind giving this one a look when you get a chance? I only ask as you've been modifying the debugger recently, and figured it would fit into what you were already doing. Any help in getting this one resolved is appreciated.

ajrhacker commented 2 years ago

Qt programming is not really my department, though this bug does affect my builds. It seems situational: hard-resetting raiden before execution has started reliably segfaults, but doing the same while the machine is running doesn't segfault. It's reproducible on certain sets but not others.

cuavas commented 2 years ago

This will get sorted out when I’m done with some refactoring.

cuavas commented 2 years ago

Fixed by 76541e8c81f1a38707bd4d1c973f6e4f86478de5.