mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 17:16:33 +08:00
Fix subtle race with slave allocation
When allocating a slave we set both is_searching and splitPoint under lock protection. Unfortunatly the order in which the variables are set is not defined. This article was very clarifying: http://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming/ So when in idle loop we test for is_searching and then access splitPoint, it could happen that splitPoint is still not updated leading to a possible crash. Fix the race lock protecting splitPoint access. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -123,12 +123,12 @@ private:
|
||||
friend struct Thread;
|
||||
|
||||
Thread threads[MAX_THREADS + 1]; // Last one is used as a timer
|
||||
Lock threadsLock;
|
||||
Lock splitLock;
|
||||
WaitCondition sleepCond;
|
||||
Depth minimumSplitDepth;
|
||||
int maxThreadsPerSplitPoint;
|
||||
int activeThreads;
|
||||
bool useSleepingThreads;
|
||||
WaitCondition sleepCond;
|
||||
};
|
||||
|
||||
extern ThreadsManager Threads;
|
||||
|
||||
Reference in New Issue
Block a user