Skip to content

Commit a63e46a

Browse files
authored
Merge pull request #16 from js6pak/fix-exit-crash
Fix Gen2GcCallback causing crashes during shutdown on mono
2 parents 7ec40c0 + 1bcf9a2 commit a63e46a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/MonoMod.Backports/System/Gen2GcCallback.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,11 @@ public static void Register(Func<object, bool> callback, object targetObj)
108108
}
109109
}
110110

111-
// Resurrect ourselves by re-registering for finalization.
112-
GC.ReRegisterForFinalize(this);
111+
if (!Environment.HasShutdownStarted)
112+
{
113+
// Resurrect ourselves by re-registering for finalization.
114+
GC.ReRegisterForFinalize(this);
115+
}
113116
}
114117
#pragma warning restore CA1031 // Do not catch general exception types
115118
}

0 commit comments

Comments
 (0)