1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Fix a crash on exit

In Thread::idle_loop() we now access main thread data,
namely Threads.main()->thinking

So upon exit we have to ensure main thread is the last
one to be deleted. It can be easily reproduced setting
more then one thread and then quitting.

This bug happens also in original lazy_smp but for some
reason remains hidden.

Although a crash, this should not compromise TCEC version
because it occurs only upon exiting the engine.

No functional change.
This commit is contained in:
Marco Costalba 2015-10-08 10:11:16 +02:00
parent dee1bd8ebc
commit 494aeb199d

View file

@ -190,8 +190,10 @@ void ThreadPool::exit() {
timer = nullptr;
for (Thread* th : *this)
delete_thread(th);
if (th != Threads.main())
delete_thread(th);
delete_thread(Threads.main()); // Must be the last one
clear(); // Get rid of stale pointers
}