gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] valgrind_3_7.1: fix in sniff_lunch()


From: Gunnar Farneback
Subject: Re: [gnugo-devel] valgrind_3_7.1: fix in sniff_lunch()
Date: Fri, 30 Aug 2002 18:53:44 +0200
User-agent: EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/20.7 (sparc-sun-solaris2.7) (with unibyte mode)

Arend wrote:
> The tool valgrind (http://developer.kde.org/~sewardj/) is, if I understand
> correctly, perfect in detecting use of uninitialized memory (it may also
> have a good chance at capturing out-of-bound memory access).

Yes, this seems to be a very competent tool.
 
> I tried it out with gnugo (it is very easy to use: "valgrind gnugo"), and
> it immediately had two complaints, one of them relevant. (I've fixed the
> other one too.) With the patch applied, there were no further problems so
> far (it's pretty slow, so I've only run half the lazarus test suite).

I actually tried it too a few weeks ago but never got around to
reporting the results (and my fixes got mixed up with a larger patch
that still isn't ready). I believe the patch below may be those fixes.

I'm not sure I understand the problem in cache.c but at the very least
the fix gives a minor speedup. The change in interface.c fixes a real
bug.

- bugfix in hashtable_partially_clear()
- bugfix in gameinfo_play_sgftree_rot()

/Gunnar

Index: engine/cache.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/cache.c,v
retrieving revision 1.13
diff -u -r1.13 cache.c
--- engine/cache.c      7 Apr 2002 12:40:25 -0000       1.13
+++ engine/cache.c      29 Aug 2002 11:08:12 -0000
@@ -371,13 +371,14 @@
    */
   for (k = 0; k < table->num_nodes; k++) {
     node = &(table->all_nodes[k]);
-    bucket = node->key.hashval[0] % table->hashtablesize;
-    previous = NULL;
-    current = table->hashtable[bucket];
 
     /* If there are no results attached, this node is not in the table. */
     if (node->results == NULL)
       continue;
+
+    bucket = node->key.hashval[0] % table->hashtablesize;
+    previous = NULL;
+    current = table->hashtable[bucket];
 
     /* Remove all closed results for this node except OWL_{ATTACK,DEFEND}. */
     hashtable_unlink_closed_results(node, 
Index: engine/interface.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/interface.c,v
retrieving revision 1.25
diff -u -r1.25 interface.c
--- engine/interface.c  18 Aug 2002 21:41:02 -0000      1.25
+++ engine/interface.c  29 Aug 2002 11:08:35 -0000
@@ -568,7 +568,7 @@
        /* following really should not be needed for proper sgf file */
        if (movenum != 0 && !addstone) {
          gnugo_sethand(gameinfo->handicap, 0);
-         sgfOverwritePropertyInt(head, "HA", handicap);
+         sgfOverwritePropertyInt(head, "HA", gameinfo->handicap);
        }
 
        /* Due to a bad comment in the SGF FF3 definition (in the
@@ -590,7 +590,7 @@
        /* following really should not be needed for proper sgf file */
        if (movenum != 0 && !addstone) {
          gnugo_sethand(gameinfo->handicap, 0);
-         sgfOverwritePropertyInt(head, "HA", handicap);
+         sgfOverwritePropertyInt(head, "HA", gameinfo->handicap);
        }
 
        if (movenum == until - 1) {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]