Bug 398722 - Crash when trying to move a pawn two squares
Summary: Crash when trying to move a pawn two squares
Status: RESOLVED FIXED
Alias: None
Product: knights
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Alexander Semke
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-16 15:06 UTC by Luigi Toscano
Modified: 2018-09-16 22:11 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
backtrace using gdb (14.28 KB, text/plain)
2018-09-16 15:07 UTC, Luigi Toscano
Details
backtrace from drkonqi (11.32 KB, text/plain)
2018-09-16 15:08 UTC, Luigi Toscano
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Luigi Toscano 2018-09-16 15:06:31 UTC
When moving a pawn two squares, the games crashes.
It can be reproduced on the current git master (f7c13d09cc95ee3aa47d56a17f6c4abe6e0540d6).

The relevant backtrace section contains:

#0  tcache_get (tc_idx=1) at malloc.c:2943
#1  __GI___libc_malloc (bytes=40) at malloc.c:3050
#2  0x00007ffff581eac8 in QMapDataBase::createNode(int, int, QMapNodeBase*, bool) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#3  0x00005555555f17aa in QMapData<Knights::Rules::Direction, Knights::Pos>::createNode(Knights::Rules::Direction const&, Knights::Pos const&, QMapNode<Knights::Rules::Direction, Knights::Pos>*, bool) ()
#4  0x00005555555f04d2 in QMap<Knights::Rules::Direction, Knights::Pos>::insert(Knights::Rules::Direction const&, Knights::Pos const&) ()
#5  0x00005555555f0551 in QMap<Knights::Rules::Direction, Knights::Pos>::operator[](Knights::Rules::Direction const&) ()
#6  0x00005555555ede33 in Knights::ChessRules::moveMade(Knights::Move const&) ()
#7  0x000055555560715c in Knights::Manager::sendPendingMove() ()
#8  0x0000555555607ac6 in Knights::Manager::processMove(Knights::Move const&) ()
#9  0x00005555556077f5 in Knights::Manager::moveByBoard(Knights::Move const&) ()



It is worth noting that drkonqi is not triggered, and in fact the program does not use the KCrash framework. Interesting enough, when adding the KCrash support, the backtrace is different. I'm going to attach both.
Comment 1 Luigi Toscano 2018-09-16 15:07:22 UTC
Created attachment 115014 [details]
backtrace using gdb
Comment 2 Luigi Toscano 2018-09-16 15:08:55 UTC
Created attachment 115015 [details]
backtrace from drkonqi

I'm going to publish the patch which adds support for KCrash (and drkonqi) as soon as possible (i.e. when phabricator answers). This is the log that I get with it.
Comment 3 Antonio Rojas 2018-09-16 16:26:17 UTC
Patch https://phabricator.kde.org/D15555
Comment 4 Alexander Semke 2018-09-16 18:48:56 UTC
(In reply to Luigi Toscano from comment #0)
> When moving a pawn two squares, the games crashes.
This is not reproducible for me. Does it always crash for you independent of color and position?
Comment 5 Antonio Rojas 2018-09-16 20:09:40 UTC
Git commit 4d1d989114a054cc05d7015870865e69aba08ef8 by Antonio Rojas.
Committed on 16/09/2018 at 20:08.
Pushed by arojas into branch 'master'.

Fix crash when moving pawn two squares

Construct the QList before using it in the range based loop
Differential Revision: https://phabricator.kde.org/D15555

M  +2    -1    src/rules/chessrules.cpp

https://commits.kde.org/knights/4d1d989114a054cc05d7015870865e69aba08ef8
Comment 6 Luigi Toscano 2018-09-16 22:11:58 UTC
It was solved in the meantime, but just for the record: I could reproduce it every time, both with whites and blacks, and with pawns in different position. I compiled it locally with kdesrc-build with gcc 8.2.0 on Debian testing against a locally built Frameworks 5.50.

(see also the comment in the review).