Fix ParallelExecutor destructor deadlock - #173
Draft
rootkiller6788 wants to merge 1 commit into
Draft
Conversation
The destructor set next_task to 1 and num_tasks to 1, so the worker wait predicate (next_task < num_tasks) stayed false and workers never woke to observe the terminate flag. This deadlocked destruction of every ParallelExecutor. Store 0 instead so workers wake, observe terminate, and exit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
ParallelExecutordestructor never returns: it storesnext_task = 1while
num_tasks = 1, so the workers' wait predicatenext_task.load() < num_tasks(i.e.1 < 1) stays false and the workerthreads are never woken to observe the
terminateflag. Every constructionof
ParallelExecutor(e.g.cbrunsli/dbrunslibuilt withBRUNSLI_EXPERIMENTAL_GROUPS) therefore hangs forever at destruction.Fix: store
0instead, so0 < num_tasksis true, workers wake up,increment
busy_count, observeterminate, and exit, letting thedestructor's
finish_latch.waitcomplete.Verified with a standalone reproduction of the executor (4 threads, one
executeround): before the change it timed out at destruction; after thechange it exits cleanly.