Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ORC] Fix Task cleanup during DynamicThreadPoolTaskDispatcher::shutdown.
Threads created by DynamicThreadPoolTaskDispatcher::dispatch had been holding a unique_ptr to the most recent Task, meaning that the Task would be destroyed when the thread object was destroyed, but this would happen *after* the thread signaled the Dispatcher that it was finished. This could cause DynamicThreadPoolTaskDispatcher::shutdown to return (and consequently ExecutionSession to be destroyed) before all Tasks were destroyed, with Task destructors accessing ExecutionSession and related objects after they were freed. The fix is to reset the Task pointer immediately after it is run to trigger cleanup, *then* (if there are no other tasks to run) signal the Dispatcher that the thread is finished. This patch also updates DynamicThreadPoolTaskDispatcher::dispatch to reject any new Tasks dispatched after DynamicThreadPoolTaskDispatcher::shutdown is called.
- Loading branch information