Hangup - possible thread race condition
Issue #109
new
Sometimes I get a hangup in tactical mode, most times when it's player's turn but once happened on CPU's turn. I get the waiting clock cursor but game is unresponsive. Music keeps playing fine.
This is what gdb shows (with symbols) for thread 1:
#0 0x00007f07a3a8d12d in nanosleep () from /usr/lib/libpthread.so.0
No symbol table info available.
#1 0x00007f07a3ceef69 in SDL_Delay () from /usr/lib/libSDL-1.2.so.0
No symbol table info available.
#2 0x00000000006a5918 in MainLoop (msPerGameCycle=25) at sgp/SGP.cc:255
gameCycleMS = 2
event = {type = 1 '\001', active = {type = 1 '\001', gain = 0 '\000',
state = 2 '\002'}, key = {type = 1 '\001', which = 0 '\000',
state = 2 '\002', keysym = {scancode = 0 '\000',
sym = SDLK_UNKNOWN, mod = KMOD_NONE, unicode = 0}}, motion = {
type = 1 '\001', which = 0 '\000', state = 2 '\002', x = 0, y = 0,
xrel = 0, yrel = 0}, button = {type = 1 '\001', which = 0 '\000',
button = 2 '\002', state = 0 '\000', x = 0, y = 0}, jaxis = {
type = 1 '\001', which = 0 '\000', axis = 2 '\002', value = 0},
jball = {type = 1 '\001', which = 0 '\000', ball = 2 '\002',
xrel = 0, yrel = 0}, jhat = {type = 1 '\001', which = 0 '\000',
hat = 2 '\002', value = 0 '\000'}, jbutton = {type = 1 '\001',
which = 0 '\000', button = 2 '\002', state = 0 '\000'}, resize = {
type = 1 '\001', w = 0, h = 0}, expose = {type = 1 '\001'},
quit = {type = 1 '\001'}, user = {type = 1 '\001', code = 0,
data1 = 0x0, data2 = 0x0}, syswm = {type = 1 '\001', msg = 0x0}}
s_doGameCycles = 1 '\001'
#3 0x00000000006a600d in main (argc=1, argv=0x7fff4b29ed48) at sgp/SGP.cc:494
---Type <return> to continue, or q <return> to quit---
params = {useMod = false, modName = "", resourceVersionGiven = false,
resourceVersion = "", doUnitTests = false, showDebugMessages = false}
gameResRootPath = "/mnt/lake/games/JA2"
externalizedDataPath = "/home/user/src/ja2-stracciatella/externalized"
cm = 0x28f3fa0
exeFolder = "/home/user/src/ja2-stracciatella"
version = GV_ENGLISH
configFolderPath = "/home/user/.ja2"
configPath = "/home/user/.ja2/ja2.ini"
instead we have on thread 2:
#0 0x00007f07a2f9391d in poll () from /usr/lib/libc.so.6
No symbol table info available.
#1 0x00007f079ee64d46 in ?? () from /usr/lib/libasound.so.2
No symbol table info available.
#2 0x00007f079ee690ae in ?? () from /usr/lib/libasound.so.2
No symbol table info available.
#3 0x00007f079ee7458b in snd_pcm_mmap_writei () from /usr/lib/libasound.so.2
No symbol table info available.
#4 0x00007f07a3ccf065 in ?? () from /usr/lib/libSDL-1.2.so.0
No symbol table info available.
#5 0x00007f07a3ca3c90 in ?? () from /usr/lib/libSDL-1.2.so.0
No symbol table info available.
#6 0x00007f07a3cabe78 in ?? () from /usr/lib/libSDL-1.2.so.0
No symbol table info available.
#7 0x00007f07a3cecb09 in ?? () from /usr/lib/libSDL-1.2.so.0
No symbol table info available.
#8 0x00007f07a3a860a2 in start_thread () from /usr/lib/libpthread.so.0
No symbol table info available.
#9 0x00007f07a2f9c3dd in clone () from /usr/lib/libc.so.6
No symbol table info available.
And on thread 3:
#0 0x00007f07a3a8d12d in nanosleep () from /usr/lib/libpthread.so.0
No symbol table info available.
#1 0x00007f07a3ceef69 in SDL_Delay () from /usr/lib/libSDL-1.2.so.0
No symbol table info available.
#2 0x00007f07a3ceefa2 in ?? () from /usr/lib/libSDL-1.2.so.0
No symbol table info available.
#3 0x00007f07a3cabe78 in ?? () from /usr/lib/libSDL-1.2.so.0
No symbol table info available.
#4 0x00007f07a3cecb09 in ?? () from /usr/lib/libSDL-1.2.so.0
No symbol table info available.
#5 0x00007f07a3a860a2 in start_thread () from /usr/lib/libpthread.so.0
No symbol table info available.
#6 0x00007f07a2f9c3dd in clone () from /usr/lib/libc.so.6
No symbol table info available.
I might be wrong, but that SDL_Delay smells very bad here...