[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] cvs of 12-10-2004: mkpat crash for mingw version
From: |
Arend Bayer |
Subject: |
Re: [gnugo-devel] cvs of 12-10-2004: mkpat crash for mingw version |
Date: |
Sun, 24 Oct 2004 05:15:50 +0200 (CEST) |
Gunnar wrote:
> Teun wrote:
> > Possibly something is not initialized properly, resulting
> > in random results. ElectricFence did not reveal a problem.
> > Can someone run valgrind on mkpat?
>
> Yes, valgrind does find a problem.
> I assume this means that there's memory read out of bounds. For the
> record this only applies to mainline CVS but not to 3.6-pre2. There is
> no relevant diff in mkpat.c between these versions but after copying
> over the more recent owl_attackpats.dtr from 3.6-pre2 the problem went
> away.
Yes, -fbounds-checking gives an error at the same position. Reverting the
hunk below of arend_7_1.17 makes the problem go away. I have committed
this to CVS.
Teun, I hope your problem should be solved by this.
Arend
Index: patterns/dfa.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/patterns/dfa.c,v
retrieving revision 1.37
diff -u -p -r1.37 dfa.c
--- patterns/dfa.c 8 Jun 2004 05:52:25 -0000 1.37
+++ patterns/dfa.c 13 Sep 2004 09:23:07 -0000
@@ -113,20 +113,24 @@ member_att(dfa_t *pdfa, int att, int val
static int
union_att(dfa_t *pdfa, dfa_t *pdfa1, int att1, dfa_t *pdfa2, int att2)
{
- int att;
- int att_aux;
+ int att_aux = 0;
+ int att = 0;
+ int save1 = att1;
+ int save2 = att2;
+ if (att1 == 0 && att2 == 0)
+ return 0;
/* copy att1 in att */
- att = 0;
while (att1 != 0) {
pdfa->last_index++;
if (pdfa->last_index >= pdfa->max_indexes)
resize_dfa(pdfa, pdfa->max_states, pdfa->max_indexes + DFA_RESIZE_STEP);
att_aux = pdfa->last_index;
+ if (!att)
+ att = att_aux;
pdfa->indexes[att_aux].val = pdfa1->indexes[att1].val;
- pdfa->indexes[att_aux].next = att;
- att = att_aux;
+ pdfa->indexes[att_aux].next = att_aux + 1;
att1 = pdfa1->indexes[att1].next;
}
@@ -137,13 +141,21 @@ union_att(dfa_t *pdfa, dfa_t *pdfa1, int
if (pdfa->last_index >= pdfa->max_indexes)
resize_dfa(pdfa, pdfa->max_states, pdfa->max_indexes + DFA_RESIZE_STEP);
att_aux = pdfa->last_index;
+ if (!att)
+ att = att_aux;
pdfa->indexes[att_aux].val = pdfa2->indexes[att2].val;
- pdfa->indexes[att_aux].next = att;
- att = att_aux;
+ pdfa->indexes[att_aux].next = att_aux + 1;
}
att2 = pdfa2->indexes[att2].next;
}
+ pdfa->indexes[att_aux].next = 0;
+ if (0 && save1 != 0 && save2 != 0) {
+ fprintf(stderr, "Made union of %d and %d at %d.\n", save1, save2, att);
+ dump_dfa(stderr, pdfa);
+ dump_dfa(stderr, pdfa1);
+ dump_dfa(stderr, pdfa2);
+ }
return att;
}