Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix a crash when reaching PLY_MAX in a check position

In this case we call evaluate() being in check and this
is not allowed.

Bug found testing with reduced PLY_MAX value as suggested
by Miguel A. Ballicora on talkchess.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
  • Loading branch information...
commit d8e7ce1863d234f585193125b328e18668bd1e71 1 parent 181d34e
@mcostalba authored
Showing with 5 additions and 4 deletions.
  1. +1 −0  src/evaluate.cpp
  2. +4 −4 src/search.cpp
View
1  src/evaluate.cpp
@@ -309,6 +309,7 @@ Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID) {
assert(pos.is_ok());
assert(threadID >= 0 && threadID < THREAD_MAX);
+ assert(!pos.is_check());
memset(&ei, 0, sizeof(EvalInfo));
View
8 src/search.cpp
@@ -1048,7 +1048,7 @@ namespace {
EvalInfo ei;
if (ply >= PLY_MAX - 1)
- return evaluate(pos, ei, threadID);
+ return pos.is_check() ? quick_evaluate(pos) : evaluate(pos, ei, threadID);
// Mate distance pruning
Value oldAlpha = alpha;
@@ -1238,7 +1238,7 @@ namespace {
EvalInfo ei;
if (ply >= PLY_MAX - 1)
- return evaluate(pos, ei, threadID);
+ return pos.is_check() ? quick_evaluate(pos) : evaluate(pos, ei, threadID);
// Mate distance pruning
if (value_mated_in(ply) >= beta)
@@ -1529,8 +1529,8 @@ namespace {
else
staticValue = evaluate(pos, ei, threadID);
- if (ply == PLY_MAX - 1)
- return evaluate(pos, ei, threadID);
+ if (ply >= PLY_MAX - 1)
+ return pos.is_check() ? quick_evaluate(pos) : evaluate(pos, ei, threadID);
// Initialize "stand pat score", and return it immediately if it is
// at least beta.
Please sign in to comment.
Something went wrong with that request. Please try again.