# Linux error message
---
ERROR: This is a compiler bug.
Please report it via https://issues.dlang.org/enter_bug.cgi
with, preferably, a reduced, reproducible example and the information below.
DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction.
---
DMD v2.090.0
predefs DigitalMars Posix linux ELFv1 CRuntime_Glibc CppRuntime_Gcc LittleEndian D_Version2 all D_SIMD D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC assert D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat
binary dmd
version v2.090.0
config /etc/dmd.conf
DFLAGS -I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/x86_64-linux-gnu -L--export-dynamic -fPIC
---
core.exception.OutOfMemoryError@src/core/exception.d(647): Memory allocation failed
----------------Segmentation fault
# Windows error message
The same error appears in the Windows build (on Windows 10).
predefs DigitalMars Windows CRuntime_DigitalMars CppRuntime_DigitalMars LittleEndian D_Version2 all D_InlineAsm D_InlineAsm_X86 X86 Win32 assert D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat
version v2.089.1-dirty
# Code
import std.file, std.stdio, std.algorithm, std.array, std.path;
void print(R)(R entries, uint depth) {
entries
.map!(a => a[depth..$])
.filter!(a => a.length > 1)
.map!(a => a[1..$])
.print(depth + 1);
}
void main() {
dirEntries(".", SpanMode.depth)
.map!(a => a.name.pathSplitter.array)
.print(0);
}
Comment #1 by dlang-bugzilla — 2021-10-16T15:51:56Z
What behavior do you expect?
"print" is instantiating itself recursively with a range type that is more complicated every iteration, so this program cannot be compiled.
Comment #2 by kulhanek.5 — 2021-10-16T15:55:03Z
Be sure to set ulimit -v to something reasonable when running the test code. It'll exhaust memory and freeze up in seconds if allowed to use unlimited swap.
Comment #3 by kulhanek.5 — 2021-10-16T15:59:22Z
Vladimir: I've no problem with it failing to compile. But the error message called it a compiler bug, so I reported it.
Ideally, the behavior would be to fail to compile while indicating the error in any way other than exhausting memory. I needed to hard reboot the first time I ran it under Linux because I didn't manage to kill it before it started thrashing the swap.
Comment #4 by dlang-bugzilla — 2021-10-16T16:46:23Z
(In reply to Ray Kulhanek from comment #3)
> Ideally, the behavior would be to fail to compile while indicating the error
> in any way other than exhausting memory.
The compiler generally cannot predict that a program will exhaust all memory.
(Variation of halting problem)
Comment #5 by dlang-bugzilla — 2021-10-16T16:50:56Z