Opened 5 months ago

Closed 5 months ago

#14745 closed defect (fixed)

GUI: Crash when adding game

Reported by: criezy Owned by: sev-
Priority: high Component: GUI
Version: Keywords:
Cc: Game:

Description

I am getting a crash when adding game in ScummVM.
Version: Current master (e1fc76c372a9688a from Sunday Dec 10).
System: macOS M1
Launcher is in list mode grouped by Engine.

Backtrace:

Assertion failed: (idx < _size), function operator[], file array.h, line 234.
Process 6940 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = hit program assert
    frame #4: 0x000000010005b5ec scummvm`Common::Array<int>::operator[](this=0x0000000124d26280, idx=191) at array.h:234:3
   231 	
   232 		/** Return a reference to the element at the given position in the array. */
   233 		T &operator[](size_type idx) {
-> 234 			assert(idx < _size);
   235 			return _storage[idx];
   236 		}
   237 	
Target 0: (scummvm) stopped.
(lldb) p _size
(size_type) $0 = 191
(lldb) p idx
(size_type) $1 = 191
    frame #22: 0x000000011dbb908c dyld`start + 520
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = hit program assert
    frame #0: 0x000000019edead78 libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x000000019ee1fee0 libsystem_pthread.dylib`pthread_kill + 288
    frame #2: 0x000000019ed5a330 libsystem_c.dylib`abort + 168
    frame #3: 0x000000019ed59744 libsystem_c.dylib`__assert_rtn + 272
  * frame #4: 0x000000010005b5ec scummvm`Common::Array<int>::operator[](this=0x0000000124d26280, idx=191) at array.h:234:3
    frame #5: 0x000000010d5446a4 scummvm`GUI::GroupedListWidget::setSelected(this=0x0000000124d26080, item=105) at groupedlist.cpp:213:45
    frame #6: 0x000000010d3d2ae8 scummvm`GUI::LauncherSimple::selectTarget(this=0x0000000124b4d200, target=0x000000016fdf9020) at launcher.cpp:1083:12
    frame #7: 0x000000010d3ca888 scummvm`GUI::LauncherDialog::doGameDetection(this=0x0000000124b4d200, path=0x000000016fdf9c20) at launcher.cpp:740:4
    frame #8: 0x000000010d3c95bc scummvm`GUI::LauncherDialog::addGame(this=0x0000000124b4d200) at launcher.cpp:420:15
    frame #9: 0x000000010d3cef2c scummvm`GUI::LauncherDialog::handleCommand(this=0x0000000124b4d200, sender=0x000000013937f880, cmd=1094992967, data=0) at launcher.cpp:757:3
    frame #10: 0x000000010d3da81c scummvm`GUI::LauncherSimple::handleCommand(this=0x0000000124b4d200, sender=0x000000013937f880, cmd=1094992967, data=0) at launcher.cpp:1345:19
    frame #11: 0x000000010d3bb138 scummvm`GUI::CommandSender::sendCommand(this=0x000000013937f880, cmd=1094992967, data=0) at object.h:54:13
    frame #12: 0x000000010d4f8aec scummvm`GUI::ButtonWidget::handleMouseUp(this=0x000000013937f880, x=114, y=18, button=1, clickCount=1) at widget.cpp:408:3
    frame #13: 0x000000010d4fc164 scummvm`GUI::DropdownButtonWidget::handleMouseUp(this=0x000000013937f880, x=114, y=18, button=1, clickCount=1) at widget.cpp:549:17
    frame #14: 0x000000010d399d10 scummvm`GUI::Dialog::handleMouseUp(this=0x0000000124b4d200, x=1760, y=396, button=1, clickCount=1) at dialog.cpp:233:6
    frame #15: 0x000000010d3b8c80 scummvm`GUI::GuiManager::processEvent(this=0x000000012f937080, event=0x000000016fdfbcc0, activeDialog=0x0000000124b4d200) at gui-manager.cpp:886:17
    frame #16: 0x000000010d3b54b8 scummvm`GUI::GuiManager::runLoop(this=0x000000012f937080) at gui-manager.cpp:588:4
    frame #17: 0x000000010d3c86c8 scummvm`GUI::LauncherDialog::run(this=0x0000000124b4d200) at launcher.cpp:344:8
    frame #18: 0x000000010d3d24dc scummvm`GUI::LauncherChooser::runModal(this=0x000000016fdfc630) at launcher.cpp:1057:16
    frame #19: 0x000000010007d328 scummvm`launcherDialog() at main.cpp:118:17
    frame #20: 0x000000010007a5c8 scummvm`::scummvm_main(argc=1, argv=0x000000016fdff830) at main.cpp:751:3
    frame #21: 0x000000010006bc78 scummvm`main(argc=1, argv=0x000000016fdff830) at macosx-main.cpp:44:12

Change History (1)

comment:1 by criezy, 5 months ago

Owner: set to sev-
Resolution: fixed
Status: newclosed

The crash was fixed by adding a sanity check in 743bd78.

To add a bit more details on the context for the crash, it did not happen always when adding games. One case that seemed to trigger it systematically for me was first removing a game, which selected a group header item (another bug), in my case "SCI (SIERRA CREATIVE INTERPRETER)", and then adding the game. If I changed the selection to an actual game before adding a new game then the crash did not occur.

Note: See TracTickets for help on using tickets.