DMD crash, LDC crash, out of memory, no error display, etc

Nierjerson via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 11 14:20:05 PDT 2017


On Sunday, 9 April 2017 at 08:22:02 UTC, Rainer Schuetze wrote:
>
>
> On 08.04.2017 22:33, Nierjerson wrote:
>> The project I am working on, which is near completion:
>>
>> https://github.com/IllusionSoftware/COM2D
>>
>> Automates COM wrapping almost completely. That is, it takes a 
>> converted
>> COM idl file and generates a D wrapper which handles all the 
>> marshaling,
>> invoking, creation, etc.
>>
>> The problem is that DMD has started crashing when trying to 
>> compile the
>> complete set of interfaces. No error, warnings, etc. Just 
>> crashes.
>
> Interesting project. In Visual D I had to marshal a couple of 
> function calls manually, and that has been quite painful. 
> Automating that process would be great.
>
> A couple of notes:
> - you can compile dmd as a 64-bit process using the VS solution 
> in src/vcbuild.
>
> - when built with this compiler the compile time generated 
> string is output using about 8GB of memory.
>
> - it still crashes after that due to a stack overflow (seems to 
> be a compiler bug). You can avoid the recursion using the 
> -allinst command line option at the cost of slightly more 
> memory being used (should be very little in this project)
>
> - compilation then continues but seems to be stalled. This is 
> caused by the huge function GenerateDCOMClasses, that is still 
> compiled into the object file even though it is just used at 
> compile time. dmd is pretty slow compiling large funtions, you 
> shouldn't dare enabling optimizations for these...
>
> - eventually (using about 11 GB of memory) the object file is 
> emitted with a size of 137 MB.
>
> If possible you should avoid huge functions.
>
> Would it be feasible to make the generation a runtime tool? If 
> I understand correctly, you run idl2d on the interface file 
> anyway, so integration with idl2d would make sense, too.


Strangely enough, I removed an inner aliasSeqOf and converted a 
few static if's in to if's(calling the function at compile time) 
and the code when from 10m generation(and usually crashing) to 
10s!!! OMFG! Maybe a bit of optimization of the code and reduce 
some further issues.

(FYI, I simply converted the foreach(m; aliasSeqOf!methods) to 
foreach(m; methods) and converted the static if's to if's.)

Unfortunately it corrupts some code but if I can fix that then it 
might be a viable solution. If aliasSeqOf is that slow(60x 
factor, more or less) and all I'm using it for is to be able to 
statically iterate through an array at CT, then something is 
wrong with D. Either it needs a valid compile looping mechanism 
that doesn't require one to jump through any hoops(aliasSeqOf) or 
it needs to be optimized.


More information about the Digitalmars-d mailing list