Skip to content

Commit

Permalink
Fix #244 access to freed memory in finalizer
Browse files Browse the repository at this point in the history
I'm surprised this only happens on macOS.

I believe it is fixed as I tried >50 attempts
without reproducing the error again
  • Loading branch information
ArthaTi committed Dec 28, 2024
1 parent 0cd5999 commit a07bfd4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/fluid/future/stack.d
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,17 @@ struct Stack(T) {
out (; empty)
do {

import core.memory : GC;

// Already empty, nothing to do
if (empty) return;

// If triggered from the GC, the objects cannot be trashed, as they may not be recyclable anymore
if (GC.inFinalizer) {
_top = null;
return;
}

// Trash the bottom
_bottom.next = _trash;
_trash = _top;
Expand Down

0 comments on commit a07bfd4

Please sign in to comment.