Jump to page: 1 2
Thread overview
[BUG] dmd segfaults on sdl_syswm.d
Jan 26, 2004
Christian Schüler
Jan 26, 2004
yaneurao
Jan 26, 2004
Walter
Jan 27, 2004
Christian Schüler
Jan 27, 2004
ahiru
Jan 27, 2004
Christian Schüler
Jan 28, 2004
C
Jan 28, 2004
yaneurao
Jan 29, 2004
J C Calvarese
Feb 02, 2004
Christian Schüler
Feb 02, 2004
J C Calvarese
January 26, 2004
Hi Walter,

Using the SDL version currently available from the DedicateD page, and DMD version 0.79, I get a segfault. The module which causes trouble is sdl_syswm.d. If I comment out this module from beeing imported, no crash happens. An empty application importing sdl.d is sufficient to reproduce the bug. More specifically:

import sdl.d --> import sdl_events.d --> import sys_syswm.d --> crash


PS:
Thumbs up for the continuing improvements on D! Templates and operator
overloading hasn't been there the last time I checked D, which must have
been early 2002.

I also tried to write a litte vector3-struct with the new operator overloading and checked the asm-output of the compiler (it's kind of a thing I try with every new compiler I get my hands on).

Result 1:
I found out that the current D compiler doens't care much about the -O
switch and inlining option. This is ok, it's not an 1.0 version after all.

Result 2:
I was surprised to see the "movsd" instruction is used to copy values
around. I'm surprised because it's said to be deprecated and this is
probably a general code-generation feature of your backend and not releated
to D alone. Example:


struct vector3
{
   float x, y, z;
   vector3 opPlus( const vector3 &other )
   { vector3 result; result.x = x + other.x; .... ; return result; }
}

vector3 A, B, C;
A = B + C;

The asm of opPlus() with -O is structured like this, correct me if I'm wrong

   prolog
   mov edi, & result
   mov esi, & (default-initializer object ?)
   movsd
   movsd
   movsd
   floating point oprations
   mov edi, &A
   mov esi, &result
   movsd
   movsd
   movsd
   epilog
   ret

Besides there beeing a redundant copy and the whole function not beeing inlined, the asm makes use of the string instruction "movsd". It is believed that string instructions and other complex instructions (bit-scans for instance) don't translate well to modern processor's microcode and are deprecated in favor of writing more risc-like code. So you should do instead:

   mov edi, &A
   mov esi, &result
   mov eax, dword ptr [esi]
   mov dword ptr [edi], eax
   mov eax, dword ptr [esi+8]
   mov dword ptr [edi+8], eax
   mov eax, dword ptr [esi+16]
   mov dword ptr [edi+16], eax

Is anybody able to confirm this? (For the record, GCC does produce risc-like
output)

Greetings
Christian



January 26, 2004
In article <bv2cm8$29of$1@digitaldaemon.com>, Christian Schüler says...
>sdl_syswm.d. If I comment out this module from beeing imported, no crash
>happens. An empty application importing sdl.d is sufficient to reproduce the
>bug. More specifically:
>import sdl.d --> import sdl_events.d --> import sys_syswm.d --> crash

try to rename 'SDL_version.d' to another name.

cf.
http://www.digitalmars.com/drn-bin/wwwnews?D/21027
http://www.digitalmars.com/drn-bin/wwwnews?D/21781
http://www.digitalmars.com/drn-bin/wwwnews?D/21900

yaneurao.


January 26, 2004
"Christian Schüler" <leichenzehrer@alpenjodel.de> wrote in message news:bv2cm8$29of$1@digitaldaemon.com...
> Hi Walter,
>
> Using the SDL version currently available from the DedicateD page, and DMD version 0.79, I get a segfault. The module which causes trouble is sdl_syswm.d. If I comment out this module from beeing imported, no crash happens. An empty application importing sdl.d is sufficient to reproduce
the
> bug. More specifically:
>
> import sdl.d --> import sdl_events.d --> import sys_syswm.d --> crash

Can you please cut it down to a minimum example and post it / email it to me? Thanks.


January 27, 2004
Hi Walter,
here you are (see attachment)

----------------------------------

import sdl_syswm;

int main()
{
    return 0;
}

----------------------------------

- importing sdl_version doesn't crash
- replicating the code of sdl_syswm into the main file doesn't crash
- renaming sdl_version to sdl_ver doesn't crash

hope this helps



"Walter" <walter@digitalmars.com> schrieb im Newsbeitrag news:bv3n4g$1g6v$1@digitaldaemon.com...

> Can you please cut it down to a minimum example and post it / email it to me? Thanks.




January 27, 2004
In article <bv66ih$2ivd$1@digitaldaemon.com>, Christian SchEer says...
>import sdl_syswm;
>
>int main()
>{
>    return 0;
>}
>
>----------------------------------
>
>- importing sdl_version doesn't crash
>- replicating the code of sdl_syswm into the main file doesn't crash
>- renaming sdl_version to sdl_ver doesn't crash
>
>hope this helps

== SDL_syswm.d Line 43 ==
struct SDL_SysWMmsg {
SDL_version _version;	// !!! "version" is a D keyword
~~~~~~~~~~~
clash here

Therefore, if SDL_version.d is renamed, it will not crash.


January 27, 2004
Is this going to be fixed in the future?
Or must we assume that struct names equalling module names are not going to
be accepted by the compiler?


"ahiru" <ahiru@moephp.org> schrieb im Newsbeitrag news:bv699a$2nk9$1@digitaldaemon.com...
> In article <bv66ih$2ivd$1@digitaldaemon.com>, Christian SchEer says...
> >import sdl_syswm;
> >
> >int main()
> >{
> >    return 0;
> >}
> >
> >----------------------------------
> >
> >- importing sdl_version doesn't crash
> >- replicating the code of sdl_syswm into the main file doesn't crash
> >- renaming sdl_version to sdl_ver doesn't crash
> >
> >hope this helps
>
> == SDL_syswm.d Line 43 ==
> struct SDL_SysWMmsg {
> SDL_version _version; // !!! "version" is a D keyword
> ~~~~~~~~~~~
> clash here
>
> Therefore, if SDL_version.d is renamed, it will not crash.
>
>


January 28, 2004
I never understood why that was , it seems naturall to me to write module myClass; \n\n class myClass { } ... .  Could we get this ?

C
"Christian Schüler" <leichenzehrer@alpenjodel.de> wrote in message
news:bv6shs$nbh$1@digitaldaemon.com...
> Is this going to be fixed in the future?
> Or must we assume that struct names equalling module names are not going
to
> be accepted by the compiler?
>
>
> "ahiru" <ahiru@moephp.org> schrieb im Newsbeitrag news:bv699a$2nk9$1@digitaldaemon.com...
> > In article <bv66ih$2ivd$1@digitaldaemon.com>, Christian SchEer says...
> > >import sdl_syswm;
> > >
> > >int main()
> > >{
> > >    return 0;
> > >}
> > >
> > >----------------------------------
> > >
> > >- importing sdl_version doesn't crash
> > >- replicating the code of sdl_syswm into the main file doesn't crash
> > >- renaming sdl_version to sdl_ver doesn't crash
> > >
> > >hope this helps
> >
> > == SDL_syswm.d Line 43 ==
> > struct SDL_SysWMmsg {
> > SDL_version _version; // !!! "version" is a D keyword
> > ~~~~~~~~~~~
> > clash here
> >
> > Therefore, if SDL_version.d is renamed, it will not crash.
> >
> >
>
>


January 28, 2004
In article <bv9343$1ch1$1@digitaldaemon.com>, C says...
>I never understood why that was , it seems naturall to me to write module myClass; \n\n class myClass { } ... .  Could we get this ?

of course , you are right.

this may be a bug ,
a pity it doesn't occur in Mr.Walter's environment.

cf.
http://www.digitalmars.com/drn-bin/wwwnews?D/21886

yaneurao.


January 29, 2004
C wrote:
> I never understood why that was , it seems naturall to me to write module myClass; \n\n class myClass { } ... .  Could we get this ?

I haven't been following this thread particularly closely, but I think we can do this.  Both of the examples I attached work for me.

Does it fail when the example is more complicated (such was with importing)?  This sounds like it might be a bug.


-- 
Justin
http://jcc_7.tripod.com/d/


February 02, 2004
Hi JC
As I pointed out, the crashed only if the offending instruction was "2
modules deep".

import sdl --> import sdl_syswm --> implort sdl_version

if instead

import sdl_version

no crash happened

-chris


"J C Calvarese" <jcc7@cox.net> schrieb im Newsbeitrag news:bv9jac$28qb$1@digitaldaemon.com...
> C wrote:
> > I never understood why that was , it seems naturall to me to write
module
> > myClass; \n\n class myClass { } ... .  Could we get this ?
>
> I haven't been following this thread particularly closely, but I think we can do this.  Both of the examples I attached work for me.
>
> Does it fail when the example is more complicated (such was with importing)?  This sounds like it might be a bug.
>
>
> --
> Justin
> http://jcc_7.tripod.com/d/
>


----------------------------------------------------------------------------
----


> module mod;
>
> import std.c.stdio;
>
> struct mod
> {
> int whatever;
> }
>
>
> void main()
> {
> mod myMod;
>
> myMod.whatever = 1692;
>
> //mod myMod = new mod();
> printf("It works.\n");
> }


----------------------------------------------------------------------------
----


> module mod;
>
> import std.c.stdio;
>
> class mod
> {
> int whatever;
>
> this()
> {
> printf("Ok.  Let's go.\n");
> }
> }
>
>
> void main()
> {
> mod myMod = new mod();
> printf("It works.\n");
> }


« First   ‹ Prev
1 2