Thread overview
roll-up of old bugs: compiler GPF on vararg code
Jan 24, 2006
Sean Kelly
Jan 25, 2006
Thomas Kuehne
Jan 25, 2006
Deewiant
Jan 25, 2006
Sean Kelly
Jan 25, 2006
Sean Kelly
January 24, 2006
C:\code\d\bugs>type 101_7.d
// this code causes a compiler GPF

import std.c.stdio;


void ptype( ... )
{
    printf( "%.*s (%.*s)\n", _arguments[0].classinfo.name, _arguments[0].classin
fo.base.name );
}


class C {}


void main()
{
    char[] ca;
    wchar[] wa;
    dchar[] da;

    char* cp;
    wchar* wp;
    dchar* dp;

    ptype( ca );
    ptype( wa );
    ptype( da );

    ptype( cp );
    ptype( wp );
    ptype( dp );

    ptype( &ca );
    ptype( &wa );
    ptype( &da );

    int i;
    float f;

    ptype( i );
    ptype( f );

    C c = new C();

    ptype( c );

    long l;

    ptype( l );

    void fn() {}

    ptype( &fn );
}
C:\code\d\bugs>dmd 101_7
January 25, 2006
Sean Kelly schrieb am 2006-01-24:
> C:\code\d\bugs>type 101_7.d
> // this code causes a compiler GPF
>
> import std.c.stdio;
>
>
> void ptype( ... )
> {
>      printf( "%.*s (%.*s)\n", _arguments[0].classinfo.name,
> _arguments[0].classin
> fo.base.name );
> }
>
>
> class C {}
>
>
> void main()
> {
>      char[] ca;
>      wchar[] wa;
>      dchar[] da;
>
>      char* cp;
>      wchar* wp;
>      dchar* dp;
>
>      ptype( ca );
>      ptype( wa );
>      ptype( da );
>
>      ptype( cp );
>      ptype( wp );
>      ptype( dp );
>
>      ptype( &ca );
>      ptype( &wa );
>      ptype( &da );
>
>      int i;
>      float f;
>
>      ptype( i );
>      ptype( f );
>
>      C c = new C();
>
>      ptype( c );
>
>      long l;
>
>      ptype( l );
>
>      void fn() {}
>
>      ptype( &fn );
> }
> C:\code\d\bugs>dmd 101_7

Can't reproduce this on Linux.

Thomas


January 25, 2006
Thomas Kuehne wrote:
> Sean Kelly schrieb am 2006-01-24:
>>> C:\code\d\bugs>type 101_7.d
>>> // this code causes a compiler GPF
>>>
>>> import std.c.stdio;
>>>
>>>
>>> void ptype( ... )
>>> {
>>>      printf( "%.*s (%.*s)\n", _arguments[0].classinfo.name,
>>> _arguments[0].classin
>>> fo.base.name );
>>> }
>>>
>>>
>>> class C {}
>>>
>>>
>>> void main()
>>> {
>>>      char[] ca;
>>>      wchar[] wa;
>>>      dchar[] da;
>>>
>>>      char* cp;
>>>      wchar* wp;
>>>      dchar* dp;
>>>
>>>      ptype( ca );
>>>      ptype( wa );
>>>      ptype( da );
>>>
>>>      ptype( cp );
>>>      ptype( wp );
>>>      ptype( dp );
>>>
>>>      ptype( &ca );
>>>      ptype( &wa );
>>>      ptype( &da );
>>>
>>>      int i;
>>>      float f;
>>>
>>>      ptype( i );
>>>      ptype( f );
>>>
>>>      C c = new C();
>>>
>>>      ptype( c );
>>>
>>>      long l;
>>>
>>>      ptype( l );
>>>
>>>      void fn() {}
>>>
>>>      ptype( &fn );
>>> }
>>> C:\code\d\bugs>dmd 101_7
> 
> Can't reproduce this on Linux.
> 
> Thomas
> 
> 

Nor I, on Windows. Compiled and ran fine in both DMD 0.142 and 0.144.
January 25, 2006
Deewiant wrote:
> Thomas Kuehne wrote:
>> Sean Kelly schrieb am 2006-01-24:
>>>> C:\code\d\bugs>type 101_7.d
>>>> // this code causes a compiler GPF
>>>>
>>>> import std.c.stdio;
>>>>
>>>>
>>>> void ptype( ... )
>>>> {
>>>>      printf( "%.*s (%.*s)\n", _arguments[0].classinfo.name, _arguments[0].classin
>>>> fo.base.name );
>>>> }
>>>>
>>>>
>>>> class C {}
>>>>
>>>>
>>>> void main()
>>>> {
>>>>      char[] ca;
>>>>      wchar[] wa;
>>>>      dchar[] da;
>>>>
>>>>      char* cp;
>>>>      wchar* wp;
>>>>      dchar* dp;
>>>>
>>>>      ptype( ca );
>>>>      ptype( wa );
>>>>      ptype( da );
>>>>
>>>>      ptype( cp );
>>>>      ptype( wp );
>>>>      ptype( dp );
>>>>
>>>>      ptype( &ca );
>>>>      ptype( &wa );
>>>>      ptype( &da );
>>>>
>>>>      int i;
>>>>      float f;
>>>>
>>>>      ptype( i );
>>>>      ptype( f );
>>>>
>>>>      C c = new C();
>>>>
>>>>      ptype( c );
>>>>
>>>>      long l;
>>>>
>>>>      ptype( l );
>>>>
>>>>      void fn() {}
>>>>
>>>>      ptype( &fn );
>>>> }
>>>> C:\code\d\bugs>dmd 101_7
>> Can't reproduce this on Linux.
> 
> Nor I, on Windows. Compiled and ran fine in both DMD 0.142 and 0.144.

Weird. It even crashes DMD if I remove the stdio import and printf call, which should eliminate Ares as the cause.  This is with 0.144 for me. To me sure it wasn't a UTF issue, I retyped a trimmed down example into a different file.  It seems like it's happening if I pass a pointer or class reference to a vararg function:

void ptype( ... ) {}

void main()
{
    void fn() {}

    ptype( &fn );
}

I'll reinstall DMD and go from there.


Sean
January 25, 2006
I was wrong, Ares is the cause.  It appears that DMD has begun to require TypeInfo classes to be declared in object.d.  I'll fix it on my end.


Sean