Opened 4 months ago

Closed 3 months ago

#13413 closed defect (fixed)

COMMON: Systematic crash after adding any new game in 2.6.0git

Reported by: dwatteau Owned by: sev-
Priority: blocker Component: Common
Version: Keywords:
Cc: Game:


This is with 2.6.0git HEAD on macOS x64. This also happens with the daily builds, at least for a few weeks I'd say.

I see the same crashes on a PS3 daily build too.

How to reproduce:

  1. Just add a game, any game, for any engine (as far as I an say)
  2. Press OK
  3. ScummVM systematically crashes.

Note: The new game does get added to ScummVM, though; it is added to its configuration file, and it's there if I restart ScummVM.

(I don't have any non-ASCII string anywhere in my paths or in the configuration file.)

lldb backtrace below:

* thread #1, queue = '', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00000001003ac0fd scummvm`Common::BaseString<char32_t>::getUnsignedValue(this=0x000000010332d828, pos=0) const at base-str.cpp:788:16
   786 	TEMPLATE uint BASESTRING::getUnsignedValue(uint pos) const {
   787 		const int shift = (sizeof(uint) - sizeof(value_type)) * 8;
-> 788 		return ((uint)_str[pos]) << shift >> shift;
   789 	}
   791 	// Hash function for strings, taken from CPython.
Target 0: (scummvm) stopped.
(lldb) p pos
(uint) $0 = 0
(lldb) p _str
(Common::BaseString<char32_t>::value_type *) $1 = 0x0000000000000000
(lldb) p shift
(const int) $3 = 0
(lldb) bt
* thread #1, queue = '', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00000001003ac0fd scummvm`Common::BaseString<char32_t>::getUnsignedValue(this=0x000000010332d828, pos=0) const at base-str.cpp:788:16
    frame #1: 0x00000001003ac07b scummvm`Common::BaseString<char32_t>::hash(this=0x000000010332d828) const at base-str.cpp:793:20
    frame #2: 0x00000001002210e9 scummvm`Common::Hash<Common::U32String>::operator(this=0x0000000103080d24, s=0x000000010332d828)(Common::U32String const&) const at hash-str.h:69:12
    frame #3: 0x0000000100221008 scummvm`Common::HashMap<Common::U32String, int, Common::Hash<Common::U32String>, Common::EqualTo<Common::U32String> >::lookup(this=0x0000000103080740, key=0x000000010332d828) const at hashmap.h:502:25
    frame #4: 0x000000010021c1a1 scummvm`Common::HashMap<Common::U32String, int, Common::Hash<Common::U32String>, Common::EqualTo<Common::U32String> >::contains(this=0x0000000103080740, key=0x000000010332d828) const at hashmap.h:597:18
    frame #5: 0x00000001002237d2 scummvm`GUI::GroupedListWidget::groupByAttribute(this=0x0000000103080400) at groupedlist.cpp:133:25
    frame #6: 0x0000000100223399 scummvm`GUI::GroupedListWidget::setList(this=0x0000000103080400, list=0x00007ff7bfefcba8, colors=0x00007ff7bfefcb88) at groupedlist.cpp:70:2
    frame #7: 0x00000001001bcc3d scummvm`GUI::LauncherSimple::updateListing(this=0x0000000103042e00) at launcher.cpp:1088:9
    frame #8: 0x00000001001b99a2 scummvm`GUI::LauncherDialog::doGameDetection(this=0x0000000103042e00, path=0x00007ff7bfefdcc0) at launcher.cpp:648:4
    frame #9: 0x00000001001b933c scummvm`GUI::LauncherDialog::addGame(this=0x0000000103042e00) at launcher.cpp:400:15
    frame #10: 0x00000001001ba68b scummvm`GUI::LauncherDialog::handleCommand(this=0x0000000103042e00, sender=0x0000000101e192f0, cmd=1094992967, data=0) at launcher.cpp:666:3
    frame #11: 0x00000001001bf147 scummvm`GUI::LauncherSimple::handleCommand(this=0x0000000103042e00, sender=0x0000000101e192f0, cmd=1094992967, data=0) at launcher.cpp:1260:19
    frame #12: 0x000000010021e883 scummvm`GUI::CommandSender::sendCommand(this=0x0000000101e192f0, cmd=1094992967, data=0) at object.h:54:13
    frame #13: 0x0000000100210627 scummvm`GUI::ButtonWidget::handleMouseUp(this=0x0000000101e192f0, x=129, y=6, button=1, clickCount=1) at widget.cpp:379:3
    frame #14: 0x0000000100211698 scummvm`GUI::DropdownButtonWidget::handleMouseUp(this=0x0000000101e192f0, x=129, y=6, button=1, clickCount=1) at widget.cpp:505:17
    frame #15: 0x00000001001abaae scummvm`GUI::Dialog::handleMouseUp(this=0x0000000103042e00, x=382, y=511, button=1, clickCount=1) at dialog.cpp:233:6
    frame #16: 0x00000001001b5ab9 scummvm`GUI::GuiManager::processEvent(this=0x0000000102838e00, event=0x00007ff7bfefe878, activeDialog=0x0000000103042e00) at gui-manager.cpp:788:17
    frame #17: 0x00000001001b5086 scummvm`GUI::GuiManager::runLoop(this=0x0000000102838e00) at gui-manager.cpp:505:4
    frame #18: 0x00000001001b901a scummvm`GUI::LauncherDialog::run(this=0x0000000103042e00) at launcher.cpp:314:8
    frame #19: 0x00000001001bbcdb scummvm`GUI::LauncherChooser::runModal(this=0x00007ff7bfefe948) at launcher.cpp:952:16
    frame #20: 0x000000010004cc6b scummvm`launcherDialog() at main.cpp:106:14
    frame #21: 0x000000010004bf97 scummvm`::scummvm_main(argc=1, argv=0x00007ff7bfeffa08) at main.cpp:572:3
    frame #22: 0x000000010004825d scummvm`main(argc=1, argv=0x00007ff7bfeffa08) at macosx-main.cpp:44:12
    frame #23: 0x000000010100151e dyld`start + 462

Change History (3)

comment:1 by criezy, 4 months ago

Thank you for the bug report.
This is actually a bug I also found two weeks ago, and it only happens when grouping games in the launcher list mode.

The crash occurs because the list of games (_dataList) and the list of attributes (_attributeValues) are out of sync when GroupedListWidget::groupByAttribute is called after adding a game. The former has already been updated with the new game, but the later is not yet updated and has one less item.

The issue is in LauncherSimple::updateListing(). It first calls GroupedListWidget::setList which only updates the _dataList and then calls groupEntries() which calls GroupedListWidget::setAttributeValues, which updates the _attributeValues. But before we get there GroupedListWidget::setList called groupByAttribute() after _dataList has been updated, but before we get the new attributes list.

I started thinking how to reorganise the code to avoid this issue, but I found other issues with the way the GroupedListWidget is implemented while doing so. So it may take a bit longer to fix. And because of this it's good to have a bug to track the issue :-)

comment:2 by dwatteau, 4 months ago

Oh, I thought I had very common configuration files, but indeed I can confirm that I had just enabled that nice "Sort by Editor" setting on both setups.

Thank you for looking into this

comment:3 by sev-, 3 months ago

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


Note: See TracTickets for help on using tickets.