Skip to content

Commit 2ef53ee

Browse files
committed
Store Eval::Info in Search::Stack
Instead of a pointer. This should fix the issue of remaining with a stale pointer when for instance calling IID, but also null search verification, singular search and razoring where we call search with the same ss pointer. In this case ss->ei is overwritten in the search() call and upon returning remains stale. This patch could have a performance hit because Eval::Info is big (176 bytes) and during splitting we copy 4 ss entries. On the good side, this patch is a clean solution. Proposed by Gary. No functional change.
1 parent d810441 commit 2ef53ee

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

src/search.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,6 @@ namespace {
489489

490490
Move movesSearched[64];
491491
StateInfo st;
492-
Eval::Info ei;
493492
const TTEntry *tte;
494493
SplitPoint* splitPoint;
495494
Key posKey;
@@ -524,7 +523,6 @@ namespace {
524523
bestValue = -VALUE_INFINITE;
525524
ss->currentMove = threatMove = (ss+1)->excludedMove = bestMove = MOVE_NONE;
526525
ss->ply = (ss-1)->ply + 1;
527-
ss->ei = &ei;
528526
(ss+1)->skipNullMove = false; (ss+1)->reduction = DEPTH_ZERO;
529527
(ss+2)->killers[0] = (ss+2)->killers[1] = MOVE_NONE;
530528

@@ -594,7 +592,7 @@ namespace {
594592
// Never assume anything on values stored in TT
595593
if ( (ss->staticEval = eval = tte->eval_value()) == VALUE_NONE
596594
||(ss->evalMargin = tte->eval_margin()) == VALUE_NONE)
597-
eval = ss->staticEval = evaluate(pos, ss->evalMargin, &ei);
595+
eval = ss->staticEval = evaluate(pos, ss->evalMargin, &ss->ei);
598596

599597
// Can ttValue be used as a better position evaluation?
600598
if (ttValue != VALUE_NONE)
@@ -604,7 +602,7 @@ namespace {
604602
}
605603
else
606604
{
607-
eval = ss->staticEval = evaluate(pos, ss->evalMargin, &ei);
605+
eval = ss->staticEval = evaluate(pos, ss->evalMargin, &ss->ei);
608606
TT.store(posKey, VALUE_NONE, BOUND_NONE, DEPTH_NONE, MOVE_NONE,
609607
ss->staticEval, ss->evalMargin);
610608
}
@@ -1121,7 +1119,6 @@ namespace {
11211119
assert(depth <= DEPTH_ZERO);
11221120

11231121
StateInfo st;
1124-
Eval::Info ei;
11251122
const TTEntry* tte;
11261123
Key posKey;
11271124
Move ttMove, move, bestMove;
@@ -1178,10 +1175,10 @@ namespace {
11781175
// Never assume anything on values stored in TT
11791176
if ( (ss->staticEval = bestValue = tte->eval_value()) == VALUE_NONE
11801177
||(ss->evalMargin = tte->eval_margin()) == VALUE_NONE)
1181-
ss->staticEval = bestValue = evaluate(pos, ss->evalMargin, &ei);
1178+
ss->staticEval = bestValue = evaluate(pos, ss->evalMargin, &ss->ei);
11821179
}
11831180
else
1184-
ss->staticEval = bestValue = evaluate(pos, ss->evalMargin, &ei);
1181+
ss->staticEval = bestValue = evaluate(pos, ss->evalMargin, &ss->ei);
11851182

11861183
// Stand pat. Return immediately if static value is at least beta
11871184
if (bestValue >= beta)

src/search.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct Stack {
4949
Value evalMargin;
5050
int skipNullMove;
5151
int futilityMoveCount;
52-
Eval::Info* ei;
52+
Eval::Info ei;
5353
};
5454

5555

0 commit comments

Comments
 (0)