Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 224e35c

Browse files
committed
Fix issue 17413: Prevent deadlock in the GC init
If the program during initialization in the pressing memory environment died with the Error thrown by the GC, GC would not be usable anymore. However, dso registry unregistration will try to removeRanges. This would cause a deadlock in the GC, preventing the exit of the program. This commit prevents GC entering the recursive lock from the chain GC.fullcollect() -> Error -> dso_registry -> GC.removeRange.
1 parent d5088da commit 224e35c

File tree

1 file changed

+3
-1
lines changed
  • src/gc/impl/conservative

1 file changed

+3
-1
lines changed

src/gc/impl/conservative/gc.d

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ class ConservativeGC : GC
10931093

10941094
void removeRange(void *p) nothrow @nogc
10951095
{
1096-
if (!p)
1096+
if (!p || _isLocked)
10971097
{
10981098
return;
10991099
}
@@ -2374,12 +2374,14 @@ struct Gcx
23742374

23752375
{
23762376
// lock roots and ranges around suspending threads b/c they're not reentrant safe
2377+
ConservativeGC._isLocked = true;
23772378
rangesLock.lock();
23782379
rootsLock.lock();
23792380
scope (exit)
23802381
{
23812382
rangesLock.unlock();
23822383
rootsLock.unlock();
2384+
ConservativeGC._isLocked = false;
23832385
}
23842386
thread_suspendAll();
23852387

0 commit comments

Comments
 (0)