Skip to content
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

Merged
merged 1 commit into from Nov 6, 2018
Merged

Fix race condition in AsyncPipelinedExecutor destructor #271

merged 1 commit into from Nov 6, 2018

Conversation

JanuszL
Copy link
Contributor

@JanuszL JanuszL commented Nov 6, 2018

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

@JanuszL
Copy link
Contributor Author

JanuszL commented Nov 6, 2018

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relay -> rely

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exists -> exist

Copy link
Contributor Author

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>
@JanuszL JanuszL merged commit 2e45e52 into NVIDIA:master Nov 6, 2018
@JanuszL JanuszL deleted the fix_race branch November 6, 2018 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants