Bug 357262

Summary: Loading game leads either to ASSERT failure or to seg fault
Product: [Applications] kmahjongg Reporter: Andreas Koenig <andreas.koenig.7os6vvqr>
Component: generalAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: RESOLVED FIXED    
Severity: crash CC: kde-games-bugs, schwarzer
Priority: NOR    
Version: 0.8   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Andreas Koenig 2015-12-28 15:33:20 UTC
First of all let me declare, I'm a newbie in building KDE from sources and I may have done something stupid, so please take the report with a grain of salt. If you cannot reproduce the case, It's probably my fault.

I built kde with kdesrc-build freshly today. Playing kmahjongg went smoothely, I didn't notice misbehaviour. To make the experience reproducable, I clicked Game=>New Numbered Game and picked the number 999999999. My Kmahjongg settings have "Generate Solvable Games" off. Then I played a few moves on game 999999999, saved the game via Game=>Save and tried to load it afterwards. If the number of moves I saved was low (<74), then the game window disappeared and the console contained:

ASSERT: "uint(i) < uint(size())" in file /usr/include/x86_64-linux-gnu/qt5/QtCore/qbytearray.h, line 464

When the number of moves I saved was >= 74 the assertion was not reached, so I could play with Undo and Redo. I cannot tell how many times one must hit Undo and Redo but funny things happened, like tiles appeared with a blank face on positions that I have never seen a tile at. After a while a deg fault appears. Here is the stack trace:

(gdb) bt
#0  0x00007f7161de9f05 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#1  0x00007f7161dc2233 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#2  0x00007f7161df1eac in ?? ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#3  0x00007f7161df2106 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#4  0x00007f7161dd10d2 in QGraphicsScene::items(Qt::SortOrder) const ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#5  0x00007f7161dfa9e5 in QGraphicsView::items() const ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#6  0x000000000045526b in GameView::items (this=0xeb58c0)
    at /home/k/src/mykde/my-source-dir/kde/kdegames/kmahjongg/GameView.cpp:824
#7  0x0000000000454b7c in GameView::updateItemsOrder (this=0xeb58c0)
    at /home/k/src/mykde/my-source-dir/kde/kdegames/kmahjongg/GameView.cpp:686
#8  0x000000000045452f in GameView::addItem (this=0xeb58c0, 
    pGameItem=0x119a870, bUpdateImage=true, bUpdateOrder=true, 
    bUpdatePosition=true)
    at /home/k/src/mykde/my-source-dir/kde/kdegames/kmahjongg/GameView.cpp:570
#9  0x0000000000454680 in GameView::addItem (this=0xeb58c0, stItemPos=..., 
    bUpdateImage=true, bUpdateOrder=true, bUpdatePosition=true)
    at /home/k/src/mykde/my-source-dir/kde/kdegames/kmahjongg/GameView.cpp:586
#10 0x00000000004546ba in GameView::addItemAndUpdate (this=0xeb58c0, 
    stItemPos=...)
    at /home/k/src/mykde/my-source-dir/kde/kdegames/kmahjongg/GameView.cpp:591
#11 0x0000000000453106 in GameView::undo (this=0xeb58c0)
    at /home/k/src/mykde/my-source-dir/kde/kdegames/kmahjongg/GameView.cpp:126
#12 0x0000000000435c80 in KMahjongg::undo (this=0xeac530)
    at /home/k/src/mykde/my-source-dir/kde/kdegames/kmahjongg/kmahjongg.cpp:226
#13 0x000000000045bf51 in KMahjongg::qt_static_metacall (_o=0xeac530, 
    _c=QMetaObject::InvokeMetaMethod, _id=12, _a=0x7ffe920107e0)
    at /home/k/src/mykde/my-build-dir/kde/kdegames/kmahjongg/moc_kmahjongg.cpp:155
#14 0x00007f71611ed6ca in QMetaObject::activate(QObject*, int, int, void**) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#15 0x00007f7161aa83b2 in QAction::triggered(bool) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#16 0x00007f7161aaa838 in QAction::activate(QAction::ActionEvent) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007f7161aab18f in QAction::event(QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x00007f7161ab1ffc in QApplicationPrivate::notify_helper(QObject*, QEvent*)
    () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x00007f7161ab74c6 in QApplication::notify(QObject*, QEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007f71611beb6b in QCoreApplication::notifyInternal(QObject*, QEvent*)
    () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#21 0x00007f71615295b8 in QShortcutMap::dispatchEvent(QKeyEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#22 0x00007f71615296f1 in QShortcutMap::tryShortcutEvent(QObject*, QKeyEvent*)
    () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#23 0x00007f71614fddaa in QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#24 0x00007f7161502ea5 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#25 0x00007f71614e6e38 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#26 0x00007f714fef5dc0 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#27 0x00007f715c591fd7 in g_main_context_dispatch ()
   from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#28 0x00007f715c592230 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#29 0x00007f715c5922dc in g_main_context_iteration ()
   from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#30 0x00007f71612152df in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#31 0x00007f71611bc2fa in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#32 0x00007f71611c43dc in QCoreApplication::exec() ()
   from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#33 0x00000000004326f1 in main (argc=1, argv=0x7ffe92011418)
    at /home/k/src/mykde/my-source-dir/kde/kdegames/kmahjongg/main.cpp:72


Oh, and BTW, the bug I reported in https://bugs.kde.org/show_bug.cgi?id=353845 could not be verified as fixed. Whenever I loaded one of the games with more than 72 tiles, so that the loading was successful, then the game number in the status line did not show "999999999" but rather the number of the previous game.

Reproducible: Always

Steps to Reproduce:
1.menue Game => New Numbered Game => "999999999" => OK
2. Play game, removing tiles
3. Save game to disk
4. Load same game from disk
5. Play for a while by just hitting Undo and Redo


Actual Results:  
If the number of moves that I saved was <= 72, then on step (4) the game crashed with an assertion failure (see details above).

If the number of moves was >= 74, then on step (5) after an undetermined number of moves a segfault occurred.

Expected Results:  
Loaded games from a file should not behave differently from generated games furing normal playing.

As mentioned above, my settings are to not produce solvable games, but I just changed this setting to produce solvable games and the behaviours described above changes slightly: the assert happened for higher numbers too, so the border between assert and not assert did not stay the same. I did not try to determine the other value, I cannot imagine this would help anybody.
Comment 1 Frederik Schwarzer 2015-12-28 19:52:33 UTC
Please, if you want to add something to a specific bug report, do so. Your BTW remark might get lost here.
Thanks.
Comment 2 Andreas Koenig 2015-12-28 20:23:47 UTC
  > Please, if you want to add something to a specific bug report, do so. Your BTW
  > remark might get lost here.

Thanks Frederick, I'll keep track of it and take care that it doesn't get lost.
Comment 3 Frederik Schwarzer 2016-01-04 22:08:58 UTC
I played the standard layout a bit with game number 999999999, saved, loaded, started a new game, loaded the saved game again, used undo/redo a lot but nothing suspicious on the table.

Can you please check again on master? The assert looks very weird.
Comment 4 Andreas Koenig 2016-01-05 04:11:35 UTC
Yes, my report applied to branch "frameworks", not "master".  I just recompiled with master and that one works fine. Sorry for the omission.
Comment 5 Frederik Schwarzer 2016-01-05 05:08:17 UTC
Thanks for the reply. Closing. :)