]> git.sesse.net Git - stockfish/commitdiff
Fix subtle race with slave allocation
authorMarco Costalba <mcostalba@gmail.com>
Mon, 30 Jan 2012 13:09:20 +0000 (14:09 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 31 Jan 2012 19:19:25 +0000 (20:19 +0100)
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>

No differences found