New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix race condition in AsyncPipelinedExecutor destructor #271
Conversation
Builds 38700. |
@@ -47,6 +47,15 @@ class DLL_PUBLIC AsyncPipelinedExecutor : public PipelinedExecutor { | |||
cpu_thread_.ForceStop(); | |||
mixed_thread_.ForceStop(); | |||
gpu_thread_.ForceStop(); | |||
/* | |||
* We need to call shutdown here and not relay on cpu_thread_ destructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relay -> rely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
/* | ||
* We need to call shutdown here and not relay on cpu_thread_ destructor | ||
* as when WorkerThread destructor is called conditional variables and mutexes | ||
* from this class may no longer exists while work inside WorkerThread is still |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exists -> exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
When AsyncPipelinedExecutor is destroyed WorkerThread destructor is called as well. Inside, it waits for the running job to be completed and then thread executing it is shut down as well. The problem arises because the job that is executed inside WorkerThread uses conditionals and mutexes that are destroyed during AsyncPipelinedExecutor destruction and before WorkerThread finishes. So WorkerThread may end up hanging inside work() it needs to complete before is able to shutdown, but this work it trying to use no longer existing conditional or mutex waiting for it infinitely. Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
When AsyncPipelinedExecutor is destroyed WorkerThread destructor is called as well. Inside, it waits for the running job to be completed and then thread executing it is shut down as well. The problem arises because the job that is executed
inside WorkerThread uses conditionals and mutexes that are destroyed during AsyncPipelinedExecutor destruction and before WorkerThread finishes.
So WorkerThread may end up hanging inside work() it needs to complete before
is able to shutdown, but this work it trying to use no longer existing
conditional or mutex waiting for it infinitely.
Signed-off-by: Janusz Lisiecki jlisiecki@nvidia.com