Skip to content

Fix ParallelExecutor destructor deadlock - #173

Draft
rootkiller6788 wants to merge 1 commit into
google:masterfrom
rootkiller6788:fix-parallelexecutor-deadlock
Draft

Fix ParallelExecutor destructor deadlock#173
rootkiller6788 wants to merge 1 commit into
google:masterfrom
rootkiller6788:fix-parallelexecutor-deadlock

Conversation

@rootkiller6788

Copy link
Copy Markdown

The ParallelExecutor destructor never returns: it stores next_task = 1
while num_tasks = 1, so the workers' wait predicate
next_task.load() < num_tasks (i.e. 1 < 1) stays false and the worker
threads are never woken to observe the terminate flag. Every construction
of ParallelExecutor (e.g. cbrunsli/dbrunsli built with
BRUNSLI_EXPERIMENTAL_GROUPS) therefore hangs forever at destruction.

Fix: store 0 instead, so 0 < num_tasks is true, workers wake up,
increment busy_count, observe terminate, and exit, letting the
destructor's finish_latch.wait complete.

Verified with a standalone reproduction of the executor (4 threads, one
execute round): before the change it timed out at destruction; after the
change it exits cleanly.

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.
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.

1 participant