]> git.sesse.net Git - stockfish/commit
Fix a race at thread creation
authorMarco Costalba <mcostalba@gmail.com>
Wed, 31 Jul 2013 04:59:24 +0000 (06:59 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 31 Jul 2013 16:35:32 +0000 (18:35 +0200)
commit4d46d29efe4ee496bda2aa7ea83184d502944852
treebb95e7516eea48f4e9ec2db626777642b6c331fe
parentcc608a7aba8c1a98838f6d61e78ffacfc16b48cd
Fix a race at thread creation

At thread creation start_routine() is called
and from there the virtual function idle_loop()
because we do this inside Thread c'tor, where the
virtual mechanism is disabled, it could happen that
the base class idle_loop() is called instead.

The issue happens with TimerThread and MainThread
where, at launch, start_routine calls
Thread::idle_loop instead of the derived ones.

Normally this bug is hidden because c'tor finishes
before start_routine() is actually called in the
just created execution thread, but on some platforms
and in some cases this is not guaranteed and the
engine hangs.

Reported by Ted Wong on talkchess

No functional change.
src/platform.h
src/thread.cpp
src/thread.h