D - [BUG] dmd segfaults on sdl_syswm.d
- Christian Schüler (63/63) Jan 25 2004 Hi Walter,
- yaneurao (7/11) Jan 26 2004 try to rename 'SDL_version.d' to another name.
- Walter (5/12) Jan 26 2004 the
- Christian Schüler (71/73) Jan 27 2004 Hi Walter,
- ahiru (7/17) Jan 27 2004 == SDL_syswm.d Line 43 ==
- Christian Schüler (5/26) Jan 27 2004 Is this going to be fixed in the future?
- C (6/36) Jan 28 2004 I never understood why that was , it seems naturall to me to write modul...
- yaneurao (7/9) Jan 28 2004 of course , you are right.
- J C Calvarese (8/10) Jan 28 2004 I haven't been following this thread particularly closely, but I think
- Christian Schüler (15/53) Feb 02 2004 Hi JC
- J C Calvarese (5/8) Feb 02 2004 Thanks for re-explaining. I've reproduced the error on my own now.
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
Jan 25 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.begin 666 SDL_syswm.zip M(C<4?L[\BI-]28((ET35-N6E;$(2)""( 2*>*C-C&"L>&]D>V%'5_]YS[!D MJVREJCR,P'.NW\6T&Q' )WX:P2W$(M])#D_"\,2->2H8C%C)C0]YU+O2B&WF MX/KQ!KH/#U M".7K9GJ'JV58$9<]""EAS:&P?%/(IJ^!T; <SE_?%G/H3U:P[,]F_<E\U<-H M3/NS^?!Q,>K/8+J83=_B00MYY;R&NL+T,[B/4&^P:JX1T90[)J2M(% AV1;' ME"ED;,^1](2+/0[)($&1_5<^I59;OSAFG;#M =B TJX)!R-03$X?F?;I)Y*; M!\73 96Z>.?J]Y3OM2RH3RO1>=1H1U&[01UED2)"0 :8R(!) 4URL*5U/,>- M"RQ)N+6$! .[XXE 0%V)6D/ 23 .KJAHO(J7X\$? \G\RLOMD(DD0V84<JAL M-==M/9<OM$'2A<(]\M -;0LH."05XS/D;A\\A XO5(9O)4DR+! ZZR0IC&U5 M_ AG^$5L%>K'^S3E&U9(Y!/53[7J*X,KMI8\6 4U0!L,*#UVZ+[KFX!X^_+R MLL(MM+4]/(DB) 4"L]<B;<#K<O+4JTX* ?T7P\G\P\$23=$??S :54<$^ASU M556ON0R+H,.+Q!5H!!PF_/!SQJ5=CG.[A;^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B2- M-> CS/,EK9Z.DN6G<BPHL)/D)_WQ1G[=T?VX/^C=%"!/U6<'QSLK?^^J5.(\ M-CDLU9M".2+15H$5$T=G:.=0(;XXEZ,%3^0+9 3ZL3ZO/]D<%OR(V>< '/2" M^$V_ /U2%2-]. I_I3-]$F]J: *Z;W_N:P.17]F0SP^Y4Z6:\YLWYN$(J3FS M 8.TM^YX_P%02P$"% L4````" "HD3LPKR:-&C$$``"J" ``"P`````````! +`'0```"E" `````` ` endJan 27 2004Is 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...I never understood why that was , it seems naturall to me to write module myClass; \n\n class myClass { } ... . Could we get this ? CIn 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.Jan 28 2004C 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/Jan 28 2004Hi 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:moduleI never understood why that was , it seems naturall to me to write---------------------------------------------------------------------------- ----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"); }Feb 02 2004