www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21473] New: DMD enters infinite loop

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

          Issue ID: 21473
           Summary: DMD enters infinite loop
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: doob me.com

Compiling the following code with DMD 2.094.0 on macOS:

import std.algorithm.searching;
import std.stdio;
import std.meta;
import std.algorithm.sorting : sort;

void main()
{
    static immutable test = [
        "ια"w, "ιά", "ιο", "ιό", "ιε", "ιέ", "ιυ", "ιύ",
"ιι", "ιί", "ιω",
"ιώ", "ιϊ", "ιΐ", "ιϋ", "ιΰ", "ιη", "ιή", "ιου", "ιού",
"ιοι", "ιοί", "ιει",
"ιεί", "ιαι", "ιαί", "ιυι", "ιυί",
        "ηα", "ηά", "ηο", "ηό", "ηε", "ηέ", "ηυ", "ηύ", "ηι",
"ηί", "ηω", "ηώ",
"ηϊ", "ηΐ", "ηϋ", "ηΰ", "ηη", "ηή", "ηου", "ηού", "ηοι",
"ηοί", "ηει", "ηεί",
"ηαι", "ηαί", "ηυι", "ηυί",
        "υα", "υά", "υο", "υό", "υε", "υέ", "υυ", "υύ", "υι",
"υί", "υω", "υώ",
"υϊ", "υΐ", "υϋ", "υΰ", "υη", "υή", "υου", "υού", "υοι",
"υοί", "υει", "υεί",
"υαι", "υαί", "υυι", "υυί"
    ].sort!`a.length > b.length`().release();

    auto qaz = "οιιοιιοιιεεεείί"w.endsWith(aliasSeqOf!test);

    qaz.writeln;
}

Causes what might be an infinite loop. Eventually the compiler segfaults. This
is the backtrace from running inside a debugger:


(code=2, address=0x7ffeef3ffff8)

dmd`TemplateInstance::isDiscardable:
->  0x1001f0d35 <+5>:  pushq  %r12
    0x1001f0d37 <+7>:  pushq  %rbx
    0x1001f0d38 <+8>:  movq   %rdi, %r14
    0x1001f0d3b <+11>: movq   0x120(%rdi), %rdi
Target 0: (dmd) stopped.
(lldb) bt

(code=2, address=0x7ffeef3ffff8)



2127

dmd`toObjFile::ToObjFile::visit(TemplateInstance*) + 42


dmd`_D3dmd4mars7tryMainFmPPxaKSQz7globals5ParamZi + 8438


dmd`_D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZv + 120





dmd`TemplateInstance::needsCodegen() is repeated over 174000 times. I've
reduced the stacktrace above to save space.

Originally reported here for Windows:
https://forum.dlang.org/post/pwwlbsvjvrkatiiqguly forum.dlang.org.

--
Dec 11 2020