Skip to content

Commit

Permalink
Enter busy state while destroying threads (#412)
Browse files Browse the repository at this point in the history
The mThreadList lock is taken while doing a whole host of things, such
as scanning, or signaling.

If we don't enter the busy state, we could be paused while holding the
lock to remove the thread, and this will deadlock the collection.
  • Loading branch information
schveiguy authored Dec 4, 2024
1 parent cfc205e commit 86e75b3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sdlib/d/gc/thread.d
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ void createThread() {
}

void destroyThread() {
/**
* Note: we are about to remove the thread from the active thread
* list, we do not want to suspend, because the thread will never be
* woken up. Therefore -- no exitBusyState.
*/
enterBusyState();

threadCache.destroyThread();
gThreadState.remove(&threadCache);
}
Expand Down

0 comments on commit 86e75b3

Please sign in to comment.