Bug 22996 – [ICE] Parsing at CTFE crash the compiler

Status
NEW
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-04-07T21:58:22Z
Last change time
2024-12-13T19:22:12Z
Keywords
CTFE, ice
Assigned to
No Owner
Creator
ponce
Moved to GitHub: dmd#20087 →

Attachments

IDFilenameSummaryContent-TypeSize
1844shape-L8.zipMain source fileapplication/x-zip-compressed337376

Comments

Comment #0 by aliloko — 2022-04-07T21:58:22Z
Created attachment 1844 Main source file I lost an excellent potential contributor because he was not impressed with D, after encountering bugs and regressions. The following program he wanted to compile but exhausted memory. ------------------------------------------------------- import std.stdio; import std.string; import std.range; import std.array; import std.typecons; import std.complex; enum TEXT = import("shape-L8.txt"); enum Tuple!(double, Complex!double)[] DATA = mixin(TEXT.transformLTSpiceToCode); string transformLTSpiceToCode(string text) { string result; result.reserve(1_000_000); result ~= "["; foreach (string line; text.lineSplitter.dropOne) { string[] fields = line.split!`a == ' ' || a == '\t' || a == ','`.array; result ~= "std.typecons.Tuple!(double, std.complex.Complex!double)("; result ~= fields[0]; result ~= ",Complex!double("; result ~= fields[1]; result ~= ","; result ~= fields[2]; result ~= ")),\n"; } result ~= "]"; return result; } void main(string[] args) { writeln(DATA); } ------------------------------------------------------- To a seasoned D programmer, it is obvious why the program uses up all memory: it uses tuples, std.complex, lazy ranges, arrays liberally at CTFE. It is of course possible to make it work at CTFE with more pedestrian code. But a newfound D user will just dismiss the language without knowing he is perhaps amongst the only to use such a costly CTFE program. And then the compiler crashing is an ICE. ## To reproduce 1. unzip the attached file and get shape-L8.txt 2. run the above program DMD will crash after exhausting memory. Better outcome with -lowmem, who caps memory usage at 100mb.
Comment #1 by robert.schadek — 2024-12-13T19:22:12Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20087 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB