Bug 19413 – StackOverflow in the optimizer when trying to optimize an errorNode

Status
REOPENED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2018-11-19T18:01:54Z
Last change time
2024-12-13T19:01:22Z
Assigned to
No Owner
Creator
dlang
Moved to GitHub: dmd#19510 →

Comments

Comment #0 by dlang — 2018-11-19T18:01:54Z
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 ---
Comment #1 by dlang — 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.
Comment #2 by razvan.nitu1305 — 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?
Comment #3 by dlang — 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; } ---
Comment #4 by uplink.coder — 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) {}
Comment #5 by uplink.coder — 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.
Comment #6 by robert.schadek — 2024-12-13T19:01:22Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19510 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB