X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=f205774124063dca9e3fed76471d2e0083d89115;hp=5d2e5175b052bdc35fc5019bdf45dfa39bbd9860;hb=56e09b4cc82c1cda42815482967670499fc64b61;hpb=5894c759cd20bac8183f8c53cb833eee23e6b4eb diff --git a/src/search.cpp b/src/search.cpp index 5d2e5175..f2057741 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -442,6 +442,10 @@ bool think(const Position& pos, bool infinite, bool ponder, int side_to_move, { ActiveThreads = newActiveThreads; init_eval(ActiveThreads); + // HACK: init_eval() destroys the static castleRightsMask[] array in the + // Position class. The below line repairs the damage. + Position p(pos.to_fen()); + assert(pos.is_ok()); } // Wake up sleeping threads @@ -2982,15 +2986,15 @@ namespace { for (i = 0; i < ActiveThreads; i++) splitPoint->slaves[i] = 0; - // Copy the current search stack to the master thread - memcpy(splitPoint->sstack[master], sstck, (ply+1) * sizeof(SearchStack)); + // Copy the tail of current search stack to the master thread + memcpy(splitPoint->sstack[master] + ply - 1, sstck + ply - 1, 3 * sizeof(SearchStack)); Threads[master].splitPoint = splitPoint; // Make copies of the current position and search stack for each thread for (i = 0; i < ActiveThreads && splitPoint->cpus < MaxThreadsPerSplitPoint; i++) if (thread_is_available(i, master)) { - memcpy(splitPoint->sstack[i], sstck, (ply+1) * sizeof(SearchStack)); + memcpy(splitPoint->sstack[i] + ply - 1, sstck + ply - 1, 3 * sizeof(SearchStack)); Threads[i].splitPoint = splitPoint; splitPoint->slaves[i] = 1; splitPoint->cpus++;