Help request for debugging ICS

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: Help request for debugging ICS

Post by syzygy »

hgm wrote:(gdb) where
#0 0xf7767430 in __kernel_vsyscall ()
#1 0xf7673e33 in waitpid () from /lib32/libc.so.6
#2 0xf7610b83 in ?? () from /lib32/libc.so.6
#3 0x0804936e in segv_handler (sig=11) at ficsmain.c:177
#4 <signal handler called>
#5 0xf7574bf3 in game_ended (g=4, winner=128, why=0) at gameproc.c:349
#6 0xf7576ef0 in process_move (p=7, command=0xffa9c6d7 "b2d2")
at gameproc.c:783
#7 0xf756092a in process_prompt (command=0xffa9c6d7 "b2d2", p=<optimized out>)
at command.c:733
#8 process_input (fd=15, com_string=0xffa9c6d7 "b2d2") at command.c:818
#9 0xf75845f8 in select_loop () at network.c:605
#10 0x080491d2 in main_event_loop () at ficsmain.c:90
#11 main (argc=3, argv=0xffa9cc44) at ficsmain.c:232
(gdb)
[/code]
So it seems the ICS is crashing in game_ended(4, BLACK, 0).

Now what? How can I find out what statement in this routine caused the crash? I have no experience in using gdb.
Use "frame 5" to inspect what is going on in game_ended().
syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: Help request for debugging ICS

Post by syzygy »

hgm wrote:After many months of flawless running, the ICS on which I organize the monthly blitz tournaments suddenly became crash prone in October, and now typically crashes within the hour. Nothing was changed, neither in the ICS nor in the OS of the VPS it is running on.
Any chance you upgraded the compiler?
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Help request for debugging ICS

Post by hgm »

Not unless the provider of the VPS upgraded it. But I don't think they do such things. I never upgraded anything, as previous experiences had learned that after upgrading the OS or compiling tools I usually would not be able to compile the ICS code anymore. All repositories for this Linux version were dead anyway, so there was not much to upgrade (until Tony Soares dug up a new repository for me, above). And even if the compiler would have been upgraded, I had no reason to recompile the ICS before the crashing mania suddenly set in.

But the code section printed in gdb above seams dead wrong. 'gl' is supposed the player number of the bughouse partner, where -1 means 'invalid' (i.e. not bughouse). So it seems the if statement should actually have been "if(gl != -1)", to indicate bughouse (as the comment suggests it must).

I have no clue how code this faulty could have ever worked...

I have started a new tourney now, with the test reversed. If it doesn't crash now, I have good hopes that we solved the cause.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Help request for debugging ICS

Post by hgm »

The "frame 5" indeed fingers the same line:

Code: Select all

&#40;gdb&#41; frame 5
#5  0xf7574bf3 in game_ended (
    g=<error reading variable&#58; Unhandled dwarf expression opcode 0x0>, 
    flags2=<optimized out>, 
    why=<error reading variable&#58; Unhandled dwarf expression opcode 0x0>)
    at gameproc.c&#58;349
349	          if ((&#40;player_globals.parray&#91;game_globals.garray&#91;gl&#93;.white&#93;.b_stats.rating <= pp->availmax&#41; && &#40;player_globals.parray&#91;game_globals.garray&#91;gl&#93;.white&#93;.b_stats.rating >= pp->availmin&#41;) || (!pp->availmax&#41;) &#123;
&#40;gdb&#41; p gl
$2 = -1
&#40;gdb&#41; p g
Unhandled dwarf expression opcode 0x0
Not sure what this "dwarf expression" stuff is supposed to mean. It did not have any trouble telling the values of the arguments 'g' and 'why' of game_ended in the stack trace.

Anyway, the test tourney is still running, and started its 5th round (with 12 participants).
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Help request for debugging ICS

Post by hgm »

Six rounds completed without crashing. I am really getting my hopes up that this fixes it.

Everyone is invited for a bigger test tourney tonight 9:00 pm Amsterdam time (3:00 pm Boston time)!
Modern Times
Posts: 3547
Joined: Thu Jun 07, 2012 11:02 pm

Re: Help request for debugging ICS

Post by Modern Times »

hgm wrote: Everyone is invited for a bigger test tourney tonight 9:00 pm Amsterdam time (3:00 pm Boston time)!
I'll log an engine on that you can include.
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Help request for debugging ICS

Post by jdart »

Still might be a good idea to run it through valgrind, as Volker suggested. I am pretty sure the original authors didn't do this and there may be other suspect code it can help find.

--Jon
D Sceviour
Posts: 570
Joined: Mon Jul 20, 2015 5:06 pm

Re: Help request for debugging ICS

Post by D Sceviour »

jdart wrote:Still might be a good idea to run it through valgrind, as Volker suggested. I am pretty sure the original authors didn't do this and there may be other suspect code it can help find.

--Jon
Is there a build for Valgrind executables available?
syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: Help request for debugging ICS

Post by syzygy »

hgm wrote:The "frame 5" indeed fingers the same line:

Code: Select all

&#40;gdb&#41; frame 5
#5  0xf7574bf3 in game_ended (
    g=<error reading variable&#58; Unhandled dwarf expression opcode 0x0>, 
    flags2=<optimized out>, 
    why=<error reading variable&#58; Unhandled dwarf expression opcode 0x0>)
    at gameproc.c&#58;349
349	          if ((&#40;player_globals.parray&#91;game_globals.garray&#91;gl&#93;.white&#93;.b_stats.rating <= pp->availmax&#41; && &#40;player_globals.parray&#91;game_globals.garray&#91;gl&#93;.white&#93;.b_stats.rating >= pp->availmin&#41;) || (!pp->availmax&#41;) &#123;
&#40;gdb&#41; p gl
$2 = -1
&#40;gdb&#41; p g
Unhandled dwarf expression opcode 0x0
Not sure what this "dwarf expression" stuff is supposed to mean.
Perhaps debugging information that your gdb cannot handle. Just compile with -g.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Help request for debugging ICS

Post by hgm »

It was compiled with -g .