Thread overview
[Issue 22397] Out of memory during compilation
Oct 16, 2021
Vladimir Panteleev
Oct 16, 2021
Ray Kulhanek
Oct 16, 2021
Ray Kulhanek
Oct 16, 2021
Vladimir Panteleev
Oct 16, 2021
Vladimir Panteleev
Oct 19, 2021
Imperatorn
Dec 17, 2022
Iain Buclaw
October 16, 2021
https://issues.dlang.org/show_bug.cgi?id=22397

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dlang-bugzilla@thecybershad
                   |                            |ow.net

--- Comment #1 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
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.

--
October 16, 2021
https://issues.dlang.org/show_bug.cgi?id=22397

--- Comment #2 from Ray Kulhanek <kulhanek.5@wright.edu> ---
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.

--
October 16, 2021
https://issues.dlang.org/show_bug.cgi?id=22397

--- Comment #3 from Ray Kulhanek <kulhanek.5@wright.edu> ---
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.

--
October 16, 2021
https://issues.dlang.org/show_bug.cgi?id=22397

--- Comment #4 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
(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)

--
October 16, 2021
https://issues.dlang.org/show_bug.cgi?id=22397

--- Comment #5 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
Maybe something like this to avoid saying that out-of-memory errors are compiler bugs:

diff --git a/src/dmd/mars.d b/src/dmd/mars.d
index 54c8298ea9..344ad207e2 100644
--- a/src/dmd/mars.d
+++ b/src/dmd/mars.d
@@ -1064,10 +1064,18 @@ else
             dmd_coverSetMerge(true);
         }

-        scope(failure) stderr.printInternalFailure;
-
-        auto args = Runtime.cArgs();
-        return tryMain(args.argc, cast(const(char)**)args.argv,
global.params);
+        try
+        {
+            auto args = Runtime.cArgs();
+            return tryMain(args.argc, cast(const(char)**)args.argv,
global.params);
+        }
+        catch (OutOfMemoryError e)
+            throw e;
+        catch (Throwable e)
+        {
+            stderr.printInternalFailure;
+            throw e;
+        }
     }
 } // !NoMain

--
October 19, 2021
https://issues.dlang.org/show_bug.cgi?id=22397

Imperatorn <johan_forsberg_86@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johan_forsberg_86@hotmail.c
                   |                            |om
           Severity|normal                      |minor

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=22397

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
December 13
https://issues.dlang.org/show_bug.cgi?id=22397

--- Comment #6 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18060

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--