www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24009] New: The garbage collector tries to allocate memory

https://issues.dlang.org/show_bug.cgi?id=24009

          Issue ID: 24009
           Summary: The garbage collector tries to allocate memory while
                    the program is out of memory
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P3
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

- When the program runs out of memory, the runtime starts a GC cycle.
- While the GC is running, the program is still out of memory, so requests for
more memory from the OS will fail.
- Therefore, it should not request more memory from the OS.
- The GC requests more memory from the OS while it is running.
- Therefore, the GC may cause the program to crash when it runs out of memory.

Unfortunately I do not have a standalone reproducer, but here is a stack trace
which illustrates the problem:



core.internal.gc.impl.conservative.gc.Gcx.ToScanStack!(void*).ToScanStack.grow()
()

core.internal.gc.impl.conservative.gc.Gcx.collectRoots(void*, void*) ()

void(void*, void*) nothrow
delegate).__lambda2!(core.thread.threadbase.ScanType, void*,
void*).__lambda2(core.thread.threadbase.ScanType, void*, void*) ()

void(core.thread.threadbase.ScanType, void*, void*) nothrow delegate, void*) ()

void(core.thread.threadbase.ScanType, void*, void*) nothrow
delegate).__lambda2!(void*).__lambda2(void*) ()

void(void*) nothrow delegate) ()



core.internal.gc.impl.conservative.gc.Gcx.collectAllRoots(bool) ()

core.internal.gc.impl.conservative.gc.Gcx.markParallel(bool) ()

core.internal.gc.impl.conservative.gc.Gcx.fullcollect(bool, bool, bool) ()

core.internal.gc.impl.conservative.gc.Gcx.smallAlloc(ulong, ref ulong, uint,
const(TypeInfo)) ()

core.internal.gc.impl.conservative.gc.ConservativeGC.runLocked!(core.internal.gc.impl.conservative.gc.ConservativeGC.mallocNoSync(ulong,
uint, ref ulong, const(TypeInfo)),
core.internal.gc.impl.conservative.gc.mallocTime,
core.internal.gc.impl.conservative.gc.numMallocs, ulong, uint, ulong,
const(TypeInfo)).runLocked(ref ulong, ref uint, ref ulong, ref const(TypeInfo))
()

core.internal.gc.impl.conservative.gc.ConservativeGC.qalloc(ulong, uint, scope
const(TypeInfo)) ()


core.memory.BlkInfo_, scope const(TypeInfo), const(TypeInfo)) ()



--
Jun 22 2023