From 6790d13f34a437fabcd915132ad180dd820ffaec Mon Sep 17 00:00:00 2001 From: Jean-loup Gailly Date: Wed, 7 Apr 2010 22:34:48 +0200 Subject: [PATCH] uct_notify(): Stop background search on new game to avoid using deallocated board. --- uct/internal.h | 1 + uct/slave.c | 5 ++++- uct/uct.c | 3 +-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/uct/internal.h b/uct/internal.h index 4046875..4a037bd 100644 --- a/uct/internal.h +++ b/uct/internal.h @@ -106,6 +106,7 @@ bool uct_pass_is_safe(struct uct *u, struct board *b, enum stone color, bool pas void uct_prepare_move(struct uct *u, struct board *b, enum stone color); void uct_genmove_setup(struct uct *u, struct board *b, enum stone color); +void uct_pondering_stop(struct uct *u); /* This is the state used for descending the tree; we use this wrapper diff --git a/uct/slave.c b/uct/slave.c index 91ac453..98d726a 100644 --- a/uct/slave.c +++ b/uct/slave.c @@ -26,7 +26,10 @@ uct_notify(struct engine *e, struct board *b, int id, char *cmd, char *args, cha struct uct *u = e->data; static bool board_resized = false; - board_resized |= is_gamestart(cmd); + if (is_gamestart(cmd)) { + board_resized = true; + uct_pondering_stop(u); + } /* Force resending the whole command history if we are out of sync * but do it only once, not if already getting the history. */ diff --git a/uct/uct.c b/uct/uct.c index 0be072e..e88662a 100644 --- a/uct/uct.c +++ b/uct/uct.c @@ -30,7 +30,6 @@ struct uct_policy *policy_ucb1_init(struct uct *u, char *arg); struct uct_policy *policy_ucb1amaf_init(struct uct *u, char *arg); -static void uct_pondering_stop(struct uct *u); static void uct_pondering_start(struct uct *u, struct board *b0, struct tree *t, enum stone color); /* Maximal simulation length. */ @@ -327,7 +326,7 @@ uct_pondering_start(struct uct *u, struct board *b0, struct tree *t, enum stone /* uct_search_stop() frontend for the pondering (non-genmove) mode, and * to stop the background search for a slave in the distributed engine. */ -static void +void uct_pondering_stop(struct uct *u) { if (!thread_manager_running) -- 2.11.4.GIT