jazzyb/libforchess — Issue #14: Assertion Fails in fc_get_pawn_moves()
Author: jazzyb
Created: 2011-12-08 11:22:43+00:00
State: open
Labels: Bug

In commit d746891b63ef6c595c3aa641fc6066fd4dd52109.

The example program when run with the parameters `-d 4 2 4` results in a segfault for the moves (1: d1-e1 a5-a4 e5-e4 h4-h5).

The following GDB output shows that an assertion is failing in fc_get_pawn_moves() where the program can't find the orientation of a particular pawn.

```
libforchess.git$ gdb ./a.out
GNU gdb 6.3.50-20050815 (Apple version gdb-1515) (Sat Jan 15 08:33:48 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries ... done

(gdb) run -d 4 2 4
Starting program: /Users/jazzyb/src/libforchess.git/a.out -d 4 2 4
Reading symbols for shared libraries ++. done
1: d1-e1 :: 0s
2: warning: this program uses gets(), which is unsafe.
a5-a4
3: e5-e4 :: 0s
4: h4-h5
Assertion failed: (0), function fc_get_pawn_moves, file src/board.c, line 460.

Program received signal SIGABRT, Aborted.
0x00007fff8329b0b6 in __kill ()
(gdb) where
#0 0x00007fff8329b0b6 in __kill ()
#1 0x00007fff8333b9f6 in abort ()
#2 0x00007fff833289bc in __assert_rtn ()
#3 0x00000001000074bb in fc_get_pawn_moves (board=0x100809900, moves=0x100100180, player=FC_FOURTH) at src/board.c:460
#4 0x0000000100007d29 in fc_board_get_moves (board=0x100809900, moves=0x100100180, player=FC_FOURTH) at src/board.c:701
#5 0x00000001000056ff in alphabeta (ai=0x7fff5fbfde90, ret=0x0, player=FC_FOURTH, depth=1, alpha=-50, beta=2147483647, max=0) at src/ai.c:163
#6 0x0000000100005904 in move_and_adjust_scores (mv=0x100802190, ai=0x7fff5fbfde90, ret=0x0, player=FC_THIRD, depth=2, alpha=0x7fff5fbfdb84, beta=0x7fff5fbfdb80, max=1) at src/ai.c:217
#7 0x00000001000057d9 in alphabeta (ai=0x7fff5fbfde90, ret=0x0, player=FC_THIRD, depth=2, alpha=-50, beta=2147483647, max=1) at src/ai.c:185
#8 0x0000000100005904 in move_and_adjust_scores (mv=0x100804800, ai=0x7fff5fbfde90, ret=0x0, player=FC_SECOND, depth=3, alpha=0x7fff5fbfdc84, beta=0x7fff5fbfdc80, max=0) at src/ai.c:217
#9 0x00000001000057d9 in alphabeta (ai=0x7fff5fbfde90, ret=0x0, player=FC_SECOND, depth=3, alpha=-2147483648, beta=2147483647, max=0) at src/ai.c:185
#10 0x0000000100005904 in move_and_adjust_scores (mv=0x100807028, ai=0x7fff5fbfde90, ret=0x7fff5fbfde60, player=FC_FIRST, depth=4, alpha=0x7fff5fbfdd84, beta=0x7fff5fbfdd80, max=1) at src/ai.c:217
#11 0x00000001000057d9 in alphabeta (ai=0x7fff5fbfde90, ret=0x7fff5fbfde60, player=FC_FIRST, depth=4, alpha=-2147483648, beta=2147483647, max=1) at src/ai.c:185
#12 0x0000000100005e29 in fc_ai_next_move (ai=0x7fff5fbfde90, ret=0x7fff5fbfde60, player=FC_FIRST, depth=4, seconds=0) at src/ai.c:362
#13 0x000000010000139f in make_computer_move (game=0x7fff5fbfdfe0, player=FC_FIRST, depth=4, timeout=0) at examples/cli/simple.c:205
#14 0x000000010000104f in main (argc=5, argv=0x7fff5fbfe040) at examples/cli/simple.c:120
(gdb)
```