Cryptic DMD error

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Mon May 11 02:03:54 PDT 2009


Don wrote:
> Lars T. Kyllingstad wrote:
>> Don wrote:
>>> Lars T. Kyllingstad wrote:
>>>> Can someone with knowledge of the DMD source code please explain 
>>>> this error message for me?
>>>>
>>>> dmd: glue.c:652: virtual void FuncDeclaration::toObjFile(int): 
>>>> Assertion `!v->csym' failed.
>>>>
>>>> I had a look at the DMD source to try and make some sense of it 
>>>> myself, but didn't succeed. I am using the latest DMD, 2.029.
>>>>
>>>> I am in the middle of porting a library from D1 to D2, and as there 
>>>> is no mention of a file name, let alone a line number, I find it 
>>>> hard to narrow down the cause of the error.
>>>>
>>>> Thanks,
>>>>
>>>> -Lars
>>> Compile with -v, and you'll find the file DMD was working on when it 
>>> crashed. Please enter a test case into Bugzilla.
>>
>>
>> Thank you! Thanks to this little piece of advice, I've managed to 
>> narrow  it down enormously, and also to work around it. I'm having 
>> problems reproducing it as a simple test case, though.
>>
>> Using the -v switch, the last thing DMD says before bailing out is 
>> "function  qagiIntegrateUpper". So here's a snippet from the 
>> troublesome code:
>>
>> ---
>> Result!(Real) qagiIntegrateUpper(Real, Func)
>>   (Func f, Real a, Real epsAbs, Real epsRel, Workspace!(Real) workspace)
>> {
>>     mixin AssertRealType!("qagiIntegrate", Real);
>>     mixin AssertSignature!("qagiIntegrate", Func, Real, Real);
>>
>>     // Map onto the interval (0, 1).
>>     auto trans = transform!(Func, "f(a + (1-t)/t)/(t*t)", a)(f);
>>
>>     return qagsIntegrate(trans, cast(Real)0.0, cast(Real)1.0,
>>         epsAbs, epsRel, workspace, Rule.GK15);
>> }
>> ---
>>
>> The line that starts with "auto trans ..." is the one that causes 
>> problems. The function transform!(...)(f) does what you think it does; 
>> it takes the function f and transforms it according to the string 
>> template parameter. The result is a struct with an opCall method and a 
>> field containing a copy of the template parameter a (which is passed 
>> to the template by alias).
>>
>> I've been able to work around the error by replacing this line with 
>> the following:
>>
>> ---
>> Real b = a;
>> auto trans = transform!(Func, "f(b + (1-t)/t)/(t*t)", b)(f);
>> ---
>>
>> Thus, what is passed on to transform() is a locally declared variable, 
>> and not an argument to the function qagiIntegrateUpper(). Why this 
>> should matter, I have no idea.
> 
> There're a bit less well tested <g>. Probably you've created a wierd 
> combination of features noone has ever done before.
> 
>>
>> But, as already mentioned, I have so far not been able to create a 
>> simple test case for reproducing the bug, and I'm pretty sure nobody 
>> wants the entire code for transform() in Bugzilla...
>>
>> I'll continue working on it, though.
>>
>> -Lars
> There's quite an art to it.
> 
> If the code isn't commercial, so that you can post a test case (even if 
> it's huge), that'd still be OK. Especially if you can manage to get it 
> all into a single file. Someone posted a 3Mb source file in there once.
> 
> Try transform!(Func, "f(b)", b)(f);


Just in case anyone is interested: I finally managed to narrow it down 
quite a bit, and I've reported the bug:

     http://d.puremagic.com/issues/show_bug.cgi?id=2962

Strangely, even though it's definitely a DMD bug, it only occurs when 
the program is compiled with rdmd.

-Lars


More information about the Digitalmars-d-learn mailing list