www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Compiler segfaults if not compiling with -debug #dbugfix

reply Anonymouse <asdf asdf.net> writes:
I'd like to bring #dbugfix attention to issue 18026: Stack 
overflow in ddmd/dtemplate.d:6241, 
TemplateInstance::needsCodegen()[0].

Put simply, I can only compile my code with -debug. Without it, 
dmd and ldc segfault on all of Linux, Windows and OSX.

The smallest I can dustmite it to is to 66 lines (according to 
dscanner) across a few modules. ag0aep6g managed to reduce it 
further into one file at 
https://issues.dlang.org/show_bug.cgi?id=18026#c10, which he 
notes mostly segfaults but sometimes manages to compile. I can't 
reproduce his snippet on my machines, it may or may not work for 
you. The fickleness is a theme.

There's no place to point and say "ah, there's the bug". It's 
just something emergent from a hundred little things that 
together make up something that segfaults compilers. I only know 
that it started when I added a big named enum with a few hundred 
members, and after that it's been popping up regularly. Sometimes 
it just goes away after I make some innocent, unrelated change.

 git clone https://github.com/zorael/kameloso.git -b 
 2080-overflow1-ldc
You can try the full thing either with dub (plain or release), or just directly.
 $ dub build -b plain
 /usr/bin/dmd failed with exit code -11.
 $ dmd -c source/kameloso/*.d source/kameloso/plugins/*.d
 Segmentation fault (core dumped)
 $ ldc source/kameloso/*.d source/kameloso/plugins/*.d
 Segmentation fault
Help. Please. :c [0]: https://issues.dlang.org/show_bug.cgi?id=18026
Jun 15 2018
parent FeepingCreature <feepingcreature gmail.com> writes:
Can somebody explain what tnext does in TemplateInstance? It 
seems to be at the root of this stack overflow. The comment says 
it's "non-first instantiated instances", which is somewhat less 
than helpful.
Jun 18 2018