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.
This commit is contained in:
Marco Costalba
2013-07-31 06:59:24 +02:00
parent cc608a7aba
commit 4d46d29efe
3 changed files with 30 additions and 29 deletions

View File

@@ -94,7 +94,7 @@ struct SplitPoint {
struct Thread {
Thread();
virtual ~Thread();
virtual ~Thread() {}
virtual void idle_loop();
void notify_one();