#153510 XGammon failing w/ SIGSEGV

Package:
xgammon
Source:
xgammon
Description:
Implementation of backgammon under X
Submitter:
Jeffrey Chimene
Date:
2005-07-18 03:12:25 UTC
Severity:
normal
#153510#5
Date:
2002-07-19 00:32:49 UTC
From:
To:
Program received signal SIGSEGV, Segmentation fault.
0x1200036bc in create_possible_moves (dice_to_set=2, w=0x11ffff810,
actual_pin=1) at allow.c:69
69                   Pin[maxpin].color == turn))
(gdb) p maxpin
$1 = -2039

The fix posted previously exposed the above bug.

Here is a possible change for allow.c

Alethion:~/xgammon-0.98a$ diff -ed  ~/xgammon-0.98a.orig/allow.c allow.c
69c
             Pin[maxpin].color == turn &&
                 maxpin >= 0))
.

I'm not sure this is correct, but the program no longer crashes.

#153510#10
Date:
33979-07-21 23:12:22 UTC
From:
To:
Well, duh... C doesn't guarantee order of evaluation. If maxpin is <
zero the SIGSEGV will still occur.

I submit the following correction:

Alethion:~/xgammon-0.98a$ diff -ed  ~/xgammon-0.98a.orig/allow.c allow.c
68,69c
    while (!(Pin[maxpin < 0 ? 0 : maxpin].count &&
             Pin[maxpin < 0 ? 0 : maxpin].color == turn))

Of course, the real issue is how maxpin gets a value < zero. That's
beyond my ken.


Realizing he doesn't know C
	as he thought,

jec