X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=7c341f878f7200d321343567c249ec8fcd8964f0;hp=d54c7ebd91fbcc5379974d7556bf14a86fff2f8a;hb=5ca428402793b07b432b006056a1368f359c4ea0;hpb=dac1bcab9007e0fe4c73fda4d6e5ac5b9add435c diff --git a/src/search.cpp b/src/search.cpp index d54c7ebd..7c341f87 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -2898,7 +2898,10 @@ namespace { if (!Threads[slave].idle || slave == master) return false; - if (Threads[slave].activeSplitPoints == 0) + // Make a local copy to be sure doesn't change under our feet + int localActiveSplitPoints = Threads[slave].activeSplitPoints; + + if (localActiveSplitPoints == 0) // No active split points means that the thread is available as // a slave for any other thread. return true; @@ -2906,8 +2909,10 @@ namespace { if (ActiveThreads == 2) return true; - // Apply the "helpful master" concept if possible - if (SplitPointStack[slave][Threads[slave].activeSplitPoints - 1].slaves[master]) + // Apply the "helpful master" concept if possible. Use localActiveSplitPoints + // that is known to be > 0, instead of Threads[slave].activeSplitPoints that + // could have been set to 0 by another thread leading to an out of bound access. + if (SplitPointStack[slave][localActiveSplitPoints - 1].slaves[master]) return true; return false;