Bug 246382 - Game lock up
Summary: Game lock up
Status: RESOLVED FIXED
Alias: None
Product: knavalbattle
Classification: Applications
Component: general (show other bugs)
Version: 2.0
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Paolo Capriotti
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-31 22:59 UTC by Bas
Modified: 2013-12-15 01:04 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.12


Attachments
screenshot while kbattleship freezes (772.54 KB, image/png)
2010-07-31 22:59 UTC, Bas
Details
screenshot of game (278.60 KB, image/png)
2013-09-01 12:22 UTC, Martin Walch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bas 2010-07-31 22:59:54 UTC
Created attachment 49717 [details]
screenshot while kbattleship freezes

Version:           2.0
OS:                Linux

On a single player game while both sides have only the ship of size one left, the computer player stops shooting after some tries, the game freezes so it will not end.

Freezes like: 
- the human player cannot shoot any more
- without an endgame lost or won message.

So you just have to click new to start a new game.

Reproducible: Couldn't Reproduce




OS: Linux (i686) release 2.6.34-gentoo-r2
Compiler: i686-pc-linux-gnu-gcc
Comment 1 Martin Walch 2013-09-01 12:22:44 UTC
Created attachment 82083 [details]
screenshot of game

I had this several times, too. Maybe the screenshot can give a hint why the AI fails to continue. It looks like the AI is following a pattern, but fails to complete it.

Also, I sent SIGSEGV to the process right after making the screenshot. Here is the backtrace:

Application: Naval Battle (kbattleship), signal: Segmentation fault
Using host libthread_db library "/lib64/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f8b1304d780 (LWP 29989))]

Thread 2 (Thread 0x7f8afddac700 (LWP 30010)):
#0  0x00007f8b0fbecd43 in select () at ../sysdeps/unix/syscall-template.S:82
#1  0x00007f8b10539bb4 in QProcessManager::run (this=<optimized out>) at io/qprocess_unix.cpp:245
#2  0x00007f8b10455b18 in QThreadPrivate::start (arg=0x7f8b108c7440 <processManager()::processManager>) at thread/qthread_unix.cpp:338
#3  0x00007f8b101bcc92 in start_thread (arg=<optimized out>) at pthread_create.c:305
#4  0x00007f8b0fbf373d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115

Thread 1 (Thread 0x7f8b1304d780 (LWP 29989)):
[KCrash Handler]
#6  0x00007f8b0fbea7bf in *__GI___poll (fds=<optimized out>, nfds=<optimized out>, timeout=10117) at ../sysdeps/unix/sysv/linux/poll.c:87
#7  0x00007f8b0bd74494 in g_main_context_poll (n_fds=<optimized out>, fds=<optimized out>, priority=<optimized out>, timeout=<optimized out>, context=<optimized out>) at gmain.c:3440
#8  g_main_context_iterate (context=0x1269e40, block=<optimized out>, dispatch=<optimized out>, self=<optimized out>) at gmain.c:3141
#9  0x00007f8b0bd7456b in g_main_context_iteration (context=0x1269e40, may_block=1) at gmain.c:3207
#10 0x00007f8b105945e5 in QEventDispatcherGlib::processEvents (this=0x1246470, flags=...) at kernel/qeventdispatcher_glib.cpp:424
#11 0x00007f8b1106e3e2 in QGuiEventDispatcherGlib::processEvents (this=0x14793e0, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#12 0x00007f8b105614e8 in QEventLoop::processEvents (this=<optimized out>, flags=<error reading variable: DWARF-2 expression error: DW_OP_reg operations must be used either alone or in conjunction with DW_OP_piece or DW_OP_bit_piece.>) at kernel/qeventloop.cpp:149
#13 0x00007f8b10561975 in QEventLoop::exec (this=0x7fffcd72e1c0, flags=<error reading variable: DWARF-2 expression error: DW_OP_reg operations must be used either alone or in conjunction with DW_OP_piece or DW_OP_bit_piece.>) at kernel/qeventloop.cpp:204
#14 0x00007f8b10567843 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1218
#15 0x000000000041ea33 in main (argc=<optimized out>, argv=<optimized out>) at /var/tmp/portage/kde-base/knavalbattle-4.11.0/work/knavalbattle-4.11.0/src/main.cpp:78
Comment 2 Jaime Torres 2013-10-02 14:00:34 UTC
The problem comes when 
illegal move ( -1 , -1 ) for player x is reached in
Controller::finalizeShot.

I see two solutions:
* Improve the AI to not shoot an illegal move
* make the AI surrender in that case.
Comment 3 Jaime Torres 2013-11-28 19:20:45 UTC
Git commit b41f5254b3365aefac3637bd23fb3a176fcb6516 by Jaime Torres.
Committed on 28/11/2013 at 19:12.
Pushed by jtamate into branch 'KDE/4.12'.

always return a valid move to avoid the game freeze

When Controller::finalizeShot receives an Illegal move, it just does
not know what to do next, and the game freeze.
This patch implements the last option to return a valid move, searching
for a free cell one by one, therefore it becomes impossible to return
an Illegal move because or the computer wins or the opponen wins before
the board is empty of free cells.

Another solution for dummyAI could be to implement a list of
free cells and choose on them randomly.
FIXED-IN: KDE/4.12
REVIEW: 113854

M  +12   -0    src/ai/ai.cpp
M  +1    -0    src/ai/ai.h
M  +2    -3    src/ai/dummyai.cpp
M  +8    -2    src/ai/smartai.cpp

http://commits.kde.org/knavalbattle/b41f5254b3365aefac3637bd23fb3a176fcb6516
Comment 4 Jaime Torres 2013-11-28 19:21:24 UTC
Git commit e7e05ad435d72a0ac32d9e573e6d04b0a97a02f2 by Jaime Torres.
Committed on 28/11/2013 at 19:12.
Pushed by jtamate into branch 'master'.

always return a valid move to avoid the game freeze

When Controller::finalizeShot receives an Illegal move, it just does
not know what to do next, and the game freeze.
This patch implements the last option to return a valid move, searching
for a free cell one by one, therefore it becomes impossible to return
an Illegal move because or the computer wins or the opponen wins before
the board is empty of free cells.

Another solution for dummyAI could be to implement a list of
free cells and choose on them randomly.
FIXED-IN: KDE/4.12
REVIEW: 113854

M  +12   -0    src/ai/ai.cpp
M  +1    -0    src/ai/ai.h
M  +2    -3    src/ai/dummyai.cpp
M  +8    -2    src/ai/smartai.cpp

http://commits.kde.org/knavalbattle/e7e05ad435d72a0ac32d9e573e6d04b0a97a02f2