Thread overview |
---|
September 03, 2004 char[] ~= causes segfault on Linux (DMD v0.101) - sc_diff.txt | ||||
---|---|---|---|---|
| ||||
Attachments: | DMD v0.101 for Linux _After_ rebuilding libphobos.a on Linux, this code will cause a segfault: void main() { char[] str; str ~= "test"; // segfault //str = str ~ "test"; // Ok } Tracing it into internal/gc/gc.d, it will cause the segfault at this line of code (dereferencing px.data is the culprit): extern (C) Array _d_arrayappend(Array *px, byte[] y, uint size) { uint cap = _gc.capacity(px.data); // segfault here Used ar to extract and obj2asm to dump the assembler from both the newly recompiled gc.o and the as-shipped gc.o. The diff file showed differences in the generated code for the _d_arrayappend function. as-shipped: _d_arrayappend: push EBP mov EBP,ESP sub ESP,0Ch push EBX mov EBX,8[EBP] ; <----------- mov EAX,_D3std2gc3_gcPS3gcx2GC push ESI push EDI mov EDI,014h[EBP] push dword ptr 4[EBX] call near ptr _D3gcx2GC8capacityFPvZk as-compiled: _d_arrayappend: push EBP mov EBP,ESP sub ESP,010h push EBX mov EBX,0Ch[EBP] ; <---------- mov EAX,_D3std2gc3_gcPS3gcx2GC push ESI push EDI mov EDI,018h[EBP] push dword ptr 4[EBX] call near ptr _D3gcx2GC8capacityFPvZk The obj2asm for the program (-O -inline -release): _Dmain: push EBP mov EBP,ESP sub ESP,8 push 1 lea EAX,-8[EBP] mov dword ptr -8[EBP],0 mov dword ptr -4[EBP],0 push dword ptr _TMP0[01Fh] push dword ptr _TMP0[021h] push EAX call near ptr _d_arrayappend add ESP,010h mov ESP,EBP pop EBP ret The relavant assembler for the non-release build is the same, and also causes the segfault. The diff file is attached. - Dave |
September 08, 2004 Re: char[] ~= causes segfault on Linux (DMD v0.101) - sc_diff.txt | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dave | Anything else I could provide regarding this? Thanks, - Dave In article <ch8ukr$172i$1@digitaldaemon.com>, Dave says... > > >DMD v0.101 for Linux > >_After_ rebuilding libphobos.a on Linux, this code will cause a segfault: > >void main() >{ >char[] str; >str ~= "test"; // segfault >//str = str ~ "test"; // Ok >} > >Tracing it into internal/gc/gc.d, it will cause the segfault at this line of code (dereferencing px.data is the culprit): > >extern (C) >Array _d_arrayappend(Array *px, byte[] y, uint size) >{ >uint cap = _gc.capacity(px.data); // segfault here > >Used ar to extract and obj2asm to dump the assembler from both the newly recompiled gc.o and the as-shipped gc.o. The diff file showed differences in the generated code for the _d_arrayappend function. > >as-shipped: >_d_arrayappend: >push EBP >mov EBP,ESP >sub ESP,0Ch >push EBX >mov EBX,8[EBP] ; <----------- >mov EAX,_D3std2gc3_gcPS3gcx2GC >push ESI >push EDI >mov EDI,014h[EBP] >push dword ptr 4[EBX] >call near ptr _D3gcx2GC8capacityFPvZk > >as-compiled: >_d_arrayappend: >push EBP >mov EBP,ESP >sub ESP,010h >push EBX >mov EBX,0Ch[EBP] ; <---------- >mov EAX,_D3std2gc3_gcPS3gcx2GC >push ESI >push EDI >mov EDI,018h[EBP] >push dword ptr 4[EBX] >call near ptr _D3gcx2GC8capacityFPvZk > >The obj2asm for the program (-O -inline -release): >_Dmain: >push EBP >mov EBP,ESP >sub ESP,8 >push 1 >lea EAX,-8[EBP] >mov dword ptr -8[EBP],0 >mov dword ptr -4[EBP],0 >push dword ptr _TMP0[01Fh] >push dword ptr _TMP0[021h] >push EAX >call near ptr _d_arrayappend >add ESP,010h >mov ESP,EBP >pop EBP >ret > >The relavant assembler for the non-release build is the same, and also causes the segfault. > >The diff file is attached. > >- Dave > > >begin 0644 sc_diff.txt >M,3@T83$X-0T*/B`)"7AO<@E%0U@L14-8#0HQ.#5A,3@W+#$Y,0T*/B`)"6UO >M=@E;14%872Q%0U@-"CX@"0EM;W8)-%M%05A=+$5#6`T*/B`)"6UO=@DX6T5! >M6%TL14-8#0H^(`D);6]V"3!#:%M%05A=+$5#6`T*/B`)"6UO=@DP,3!H6T5! >M6%TL14-8#0HW-C-C-S8Y#0H\(`D)<W5B"4534"PP0V@-"BTM+0T*/B`)"7-U >M8@E%4U`L,#$P:`T*-S8U8S<W,0T*/"`)"6UO=@E%0E@L.%M%0E!=#0HM+2T- >M"CX@"0EM;W8)14)8+#!#:%M%0E!=#0HW-CEC-S<U#0H\(`D);6]V"45$22PP >M,31H6T5"4%T-"BTM+0T*/B`)"6UO=@E%1$DL,#$X:%M%0E!=#0HW-S5C-S@Q >M#0H\(`D)861D"45#6"PP0VA;14)070T*+2TM#0H^(`D)861D"45#6"PP,3!H >M6T5"4%T-"C<Y-&,X,#`-"CP@3#4Y.@D);6]V"3`Q-&A;14)072Q%1$D-"BTM >M+0T*/B!,-3DZ"0EM;W8),#$X:%M%0E!=+$5$20T*-SDV8S@P,@T*/"`)"6UO >M=@E%1%@L,#$P:%M%0E!=#0HM+2T-"CX@"0EM;W8)1418+#`Q-&A;14)070T* >M-SDX8S@P-`T*/"`)"6UO=@E%05@L,$-H6T5"4%T-"BTM+0T*/B`)"6UO=@E% >M05@L,#$P:%M%0E!=#0HX,#%C.#`W#0H\(`D):6UU;`E%1$DL,#$T:%M%0E!= >M#0HM+2T-"CX@"0EI;75L"45$22PP,3AH6T5"4%T-"C@P,V,X,#D-"CP@"0EI >M;75L"45#6"PP,31H6T5"4%T-"BTM+0T*/B`)"6EM=6P)14-8+#`Q.&A;14)0 >M70T*.#$Q83@Q.`T*/B`)"6UO=@E%4TDL.%M%0E!=#0HX,3-A.#(Q+#@R,PT* >M/B`)"6UO=@E;15-)72Q%05@-"CX@"0EM;W8)14%8+$5320T*/B`)"6UO=@DT >J6T5325TL1418#0HX,C$L.#(R9#@S,`T*/"`)"6YO<`T*/"`)"6YO<`T* >` >end |
September 11, 2004 Re: char[] ~= causes segfault on Linux (DMD v0.101) - sc_diff.txt | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dave | "Dave" <Dave_member@pathlink.com> wrote in message news:chnlj1$14uf$1@digitaldaemon.com... > > Anything else I could provide regarding this? No, I know what's wrong. The calling conventions on linux are slightly different, and that tripped me up. It's now fixed. |
September 12, 2004 Re: char[] ~= causes segfault on Linux (DMD v0.101) - sc_diff.txt | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | In article <chvn4n$3tt$1@digitaldaemon.com>, Walter says... > > >"Dave" <Dave_member@pathlink.com> wrote in message news:chnlj1$14uf$1@digitaldaemon.com... >> >> Anything else I could provide regarding this? > >No, I know what's wrong. The calling conventions on linux are slightly different, and that tripped me up. It's now fixed. > > Thanks! - Dave |
Copyright © 1999-2021 by the D Language Foundation