Fix ugly mistake in BLI_task - freeing while some tasks are still being processed.

Freeing pool was calling `BLI_task_pool_stop()`, which only clears
pool's tasks that are in TODO queue, whithout ensuring no more tasks
from that pool are being processed in worker threads.

This could lead to use-after-free random (and seldom) crashes.

Now use instead `BLI_task_pool_cancel()`, which does waits for all tasks
being processed to finish, before returning.
This commit is contained in:
Bastien Montagne 2017-03-03 17:12:03 +01:00
parent 5f05dac28f
commit 18c2a44333

@ -565,7 +565,7 @@ TaskPool *BLI_task_pool_create_background(TaskScheduler *scheduler, void *userda
void BLI_task_pool_free(TaskPool *pool)
{
BLI_task_pool_stop(pool);
BLI_task_pool_cancel(pool);
BLI_mutex_end(&pool->num_mutex);
BLI_condition_end(&pool->num_cond);