Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StackOverflow in the optimizer when trying to optimize an errorNode #19510

Open
dlangBugzillaToGithub opened this issue Nov 19, 2018 · 5 comments
Labels
Arch:x86_64 Issues specific to x86_64 P3 Severity:normal

Comments

@dlangBugzillaToGithub
Copy link

dlang reported this on 2018-11-19T18:01:54Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=19413

CC List

  • RazvanN
  • Stefan Koch

Description

Tested on Windows DMD 2081.2 and 2083.0
On Linux 2.065.0 and 2082.0

Compiler segfaults when assigning from a slice to an AA that contains another array in CTFE.

Does not occur if executed at runtime or with a string[string].

---
void main() { enum a = d(); }

auto d() {
    alias VP = string[string];
    VP[string] values;
    string str = "aaaaaa";
    values[str]["s"] = "val";

    str = str[1..3];
    values[str]["s"] = "val"; // <-- right here.

    return values;
}
---
---
DMD v2.083.0

predefs   Have_new 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
binary    C:\D\dmd2\windows\bin\dmd.exe
version   v2.083.0

config    C:\D\dmd2\windows\bin\sc.ini
DFLAGS    -IC:\D\dmd2\windows\bin\..\..\src\phobos -IC:\D\dmd2\windows\bin\..\..\src\druntime\import
---
@dlangBugzillaToGithub
Copy link
Author

dlang (@Vild) commented on 2018-11-20T11:58:14Z

run.dlang.io runs this successfully from 2.061 to 2.080.1; it segfaults from 2.081.1 to current.

@dlangBugzillaToGithub
Copy link
Author

razvan.nitu1305 commented on 2018-11-21T12:22:58Z

This is the output I get on run.dlang.io:

Up to      2.060  : Failure with output:
-----
onlineapp.d(4): Error: no identifier for declarator VP
onlineapp.d(4): Error: alias cannot have initializer
-----

Since      2.061  : Success and no output

Maybe close this as invalid?

@dlangBugzillaToGithub
Copy link
Author

dlang (@Vild) commented on 2018-11-22T13:00:53Z

I'm sorry; I'd removed a writeln on run.dlang.io before posting it here but didn't test it. The writeln isn't necessary when I run it locally.

---
import std.stdio;

void main() { enum a = d(); writeln(a); }

auto d() {
    alias VP = string[string];
    VP[string] values;
    string str = "aaaaaa";
    values[str]["s"] = "val";

    str = str[1..3];
    values[str]["s"] = "val"; // <-- right here.

    return values;
}
---

@dlangBugzillaToGithub
Copy link
Author

uplink.coder commented on 2018-11-22T14:49:36Z

This does not seem to be a CTFE issue.

It's a problem where the optimizer will try to optimise an invalid node.

Also there is no need to use writeln, you can replace the writeln by void use(A)(A a) {}

@dlangBugzillaToGithub
Copy link
Author

uplink.coder commented on 2018-11-22T15:23:38Z

Some more information:

What happens is actually a stack-overflow in optimize.d:1209

I guess my guess is that error-nodes do compare false to all other nodes since an error node does make it through. the Optimizer can never verify that the fixed point has been reached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch:x86_64 Issues specific to x86_64 P3 Severity:normal
Projects
None yet
Development

No branches or pull requests

1 participant