mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Fix use of an initialized SearchStack
In RootMoveList c'tor we allocate a search stack and then call directly qsearch. There is called init_node() that clears all the fields of the search stack array that refers to current ply but not the the killer moves. The killer moves cleared correspond to ply+2. In id_loop() this is not a problem because killer moves of corresponding ply are cleared anyway few instructions later, but in RootMoveList c'tor we leave them uninitialized. This patch fixes this very old bug. It comes direclty from Glaurung age. Bug spotted by Valgrind. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
e49b21eacb
commit
da948cc94e
1 changed files with 15 additions and 5 deletions
|
@ -299,6 +299,7 @@ namespace {
|
|||
void ponderhit();
|
||||
void print_current_line(SearchStack ss[], int ply, int threadID);
|
||||
void wait_for_stop_or_ponderhit();
|
||||
void init_ss_array(SearchStack ss[]);
|
||||
|
||||
void idle_loop(int threadID, SplitPoint* waitSp);
|
||||
void init_split_point_stack();
|
||||
|
@ -636,11 +637,7 @@ namespace {
|
|||
// Initialize
|
||||
TT.new_search();
|
||||
H.clear();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
ss[i].init(i);
|
||||
ss[i].initKillers();
|
||||
}
|
||||
init_ss_array(ss);
|
||||
IterationInfo[1] = IterationInfoType(rml.get_move_score(0), rml.get_move_score(0));
|
||||
Iteration = 1;
|
||||
|
||||
|
@ -1961,6 +1958,7 @@ namespace {
|
|||
// Find a quick score for the move
|
||||
StateInfo st;
|
||||
SearchStack ss[PLY_MAX_PLUS_2];
|
||||
init_ss_array(ss);
|
||||
|
||||
moves[count].move = cur->move;
|
||||
pos.do_move(moves[count].move, st);
|
||||
|
@ -2560,6 +2558,18 @@ namespace {
|
|||
}
|
||||
|
||||
|
||||
// init_ss_array() does a fast reset of the first entries of a SearchStack array
|
||||
|
||||
void init_ss_array(SearchStack ss[]) {
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
ss[i].init(i);
|
||||
ss[i].initKillers();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// wait_for_stop_or_ponderhit() is called when the maximum depth is reached
|
||||
// while the program is pondering. The point is to work around a wrinkle in
|
||||
// the UCI protocol: When pondering, the engine is not allowed to give a
|
||||
|
|
Loading…
Add table
Reference in a new issue