[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] stack overflow
From: |
Arend Bayer |
Subject: |
Re: [gnugo-devel] stack overflow |
Date: |
Sat, 22 Feb 2003 19:14:12 +0100 (MET) |
On Sat, 22 Feb 2003 address@hidden wrote:
>
> > FYI, the new new_semeai() function allocates 1,5 Mb on the stack. The VC++
> > build doesn't seem to be up to this, and crashes as soon as the function
> > is called.
> >
> > /nando
>
> Sorry. We need to allocate an array based on how many dragons
> there are or guess a safe upper bound. I guessed 361. This
> makes the array size 361^2 and I guess that's too much.
> Index: engine/semeai.c
> ===================================================================
> RCS file: /cvsroot/gnugo/gnugo/engine/semeai.c,v
> retrieving revision 1.50
> diff -u -r1.50 semeai.c
> --- engine/semeai.c 21 Feb 2003 23:39:50 -0000 1.50
> +++ engine/semeai.c 22 Feb 2003 17:16:58 -0000
> @@ -94,7 +94,7 @@
> * owl_analyze_semeai() instead of relying on static analysis.
> */
>
> -#define MAX_DRAGONS MAX_BOARD*MAX_BOARD
> +#define MAX_DRAGONS 50
>
> void
> new_semeai(int color)
> @@ -105,8 +105,10 @@
> int d1, d2;
> int k;
> int other = OTHER_COLOR(color);
> + int num_dragons = number_of_dragons;
>
> - gg_assert (number_of_dragons <= MAX_DRAGONS);
> + if (num_dragons > MAX_DRAGONS)
> + num_dragons = MAX_DRAGONS;
>
> for (d1 = 0; d1 < number_of_dragons; d1++)
> for (d2 = 0; d2 < number_of_dragons; d2++) {
I suppose you want to change all occurences of number_of_dragons below to
num_dragons? The way it is, it looks like a (pretty unlikely) array bound
violation to me if number_of_dragons > MAX_DRAGONS.
Could we, instead, maybe just use a single array for all semeai fights?
Arend