Summary: | knetwalk crashes on game won if there is exactly 1 entry in highscorelist | ||
---|---|---|---|
Product: | [Applications] knetwalk | Reporter: | Sune Vuorela <debian> |
Component: | general | Assignee: | Fela Winkelmolen <fela.kde> |
Status: | RESOLVED FIXED | ||
Severity: | crash | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Debian testing | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | patch to hopefully fix knetwalk crash |
Description
Sune Vuorela
2006-11-09 00:13:58 UTC
This is also debian #388619 (http://bugs.debian.org/nnnn) and 383442 347757 361514 /Sune and sometimes I can only reproduce it when there is no knetwalkrc :/ /Sune I can't reproduce it, but here is what could be happening as far as I can tell: knetwalk never calls setScoreHistogram() on it's Manager subclass object, so createHistoItems() is never called on the PlayerInfos object. Therefore, _histogram has size 0, but _bound is never initialized anywhere. If _bound happens to be 0, PlayerInfos::histoSize() will return 1. So, in the code snippet reported above, i is 0 and sh.size() is 0, so we call item(histoName(0))->increment(_id) In histoName(0), we pass the Q_ASSERT (which looks buggy - I think it should be Q_ASSERT( i<sh.size() || (!_bound && i==sh.size()) ); , as right now it always passes if _bound is true, no matter what i is). Again, i == sh.size() so we return QString("nb scores greater that %1").arg(sh[-1]); Even if this doesn't crash, we now lookup "nb scores greater than X" using findIndex(), but it doesn't exist, since createHistoItems() was never called, so it returns -1. This should trigger kdError(11002) and then return the item at(-1). Finally, we call the ->increment(_id) function on the non-existent item at index -1. Anyway, this is mostly speculation, since I can't reproduce the crash, but it seems possible for this to happen from looking at the code. Created attachment 18474 [details]
patch to hopefully fix knetwalk crash
Hopefully this patch fixes the knetwalk crash. I haven't tested it, as I can't
reproduce the crash anyway, so it is only based on code analysis.
I have tried the proposed patch from jdmetz - and I have until now been unable to reproduce the crash. /Sune Actually, looking at the code this morning, it doesn't seem that that could be the cause of the crash, as the loop runs from (uint i=1; i<histoSize(); i++). I don't see how histoSize() could possibly be greater than 1 in this case, and even with histoSize() == 1, the inside of the loop should never be executed. My knetwalk crashes on game won, if I haven't selected a type of game at start. Starting knetwalk with the appropriate option solves this. For your information: I cannot reproduce the crash with KNetwalk 1.0 on KDE 3.5.7... Is it fixed? I cannot reproduce it either. steps I done : remove ~/.kde/share/config/knetwalkrc run knetwalk (in easy mode :p) win the game quit knetwalk run knetwalk win the game quit knetwalk => no crash so far. using kde 3.5.7 Could you try if the bug is reproductible for you please ? Is fixed downstream so can probably be closed now. *** Bug has been marked as fixed ***. |