May 30, 2013 [Bug 57] Comparing small structs fails | ||||
---|---|---|---|---|
| ||||
http://bugzilla.gdcproject.org/show_bug.cgi?id=57 --- Comment #10 from Iain Buclaw <ibuclaw@gdcproject.org> 2013-05-30 08:50:07 UTC --- (In reply to comment #9) > Unfortunately I can still reproduce it. > > Using GCC 4.8.0, GDC revision ed839f8a16e84d0eddaac3100dae4905ebcd58e9. Happens only without optimization and only on 64 bit. > > Compiled using "/opt/gdc/bin/gdc smallstruct.d" Are you 'sure' ? :) _D11smallstruct5funcAFZS11smallstruct1S: movq $0, (%rax) movq $0, 8(%rax) movl $4, -24(%rbp) movq $42, -16(%rbp) movq -24(%rbp), %rax movq -16(%rbp), %rdx _Dmain: movq $0, (%rax) movq $0, 8(%rax) movl $4, -64(%rbp) movq $42, -56(%rbp) call _D11smallstruct5funcAFZS11smallstruct1S -- Configure bugmail: http://bugzilla.gdcproject.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes. |
May 30, 2013 [Bug 57] Comparing small structs fails | ||||
---|---|---|---|---|
| ||||
http://bugzilla.gdcproject.org/show_bug.cgi?id=57 --- Comment #11 from Johannes Pfau <johannespfau@gmail.com> 2013-05-30 17:07:16 UTC --- I've now used a fresh clone of the gdc repository, extracted gcc 4.8.0 ad did a complete new build, but I can still reproduce this here with x86_64 and without optimization. The problem is not in the asm you posted, it's in the asm which moves the value returned from funcA from the rax/rdx register onto the stack (after the call to funcA). Here's a more complete asm listing: ------ Dump of assembler code for function _Dmain: push %rbp mov %rsp,%rbp push %r13 push %r12 push %rbx sub $0x28,%rsp lea -0x40(%rbp),%rax movq $0x0,(%rax) movq $0x0,0x8(%rax) movl $0x4,-0x40(%rbp) movq $0x2a,-0x38(%rbp) callq 0x4025e0 <_D11smallstruct5funcAFZS11smallstruct1S> mov %eax,%ecx <------- here mov %rdx,%rax mov %ecx,-0x30(%rbp) <------- and here mov %rax,-0x28(%rbp) lea -0x40(%rbp),%rcx lea -0x30(%rbp),%rax mov $0x10,%edx mov %rcx,%rsi mov %rax,%rdi callq 0x401bc0 <memcmp@plt> ------ I'll also attach the compiled binary. -- Configure bugmail: http://bugzilla.gdcproject.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes. |
May 30, 2013 [Bug 57] Comparing small structs fails | ||||
---|---|---|---|---|
| ||||
http://bugzilla.gdcproject.org/show_bug.cgi?id=57 --- Comment #12 from Johannes Pfau <johannespfau@gmail.com> 2013-05-30 17:10:12 UTC --- Created attachment 40 --> http://bugzilla.gdcproject.org/attachment.cgi?id=40 compiled binary -- Configure bugmail: http://bugzilla.gdcproject.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes. |
May 30, 2013 [Bug 57] Comparing small structs fails | ||||
---|---|---|---|---|
| ||||
http://bugzilla.gdcproject.org/show_bug.cgi?id=57 --- Comment #13 from Iain Buclaw <ibuclaw@gdcproject.org> 2013-05-30 17:56:25 UTC --- ==== iain@dm1-oneiric:~$ wget http://bugzilla.gdcproject.org/attachment.cgi?id=40 -O smallstruct iain@dm1-oneiric:~$ chmod +x smallstruct iain@dm1-oneiric:~$ ./smallstruct iain@dm1-oneiric:~$ echo $? 0 iain@dm1-oneiric:~$ file smallstruct smallstruct: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, not stripped ==== Can not reproduce running that binary on any of my x86_64 systems. :-) -- Configure bugmail: http://bugzilla.gdcproject.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes. |
May 30, 2013 [Bug 57] Comparing small structs fails | ||||
---|---|---|---|---|
| ||||
http://bugzilla.gdcproject.org/show_bug.cgi?id=57 --- Comment #14 from Iain Buclaw <ibuclaw@gdcproject.org> 2013-05-30 18:17:07 UTC --- (In reply to comment #13) > Can not reproduce running that binary on any of my x86_64 systems. :-) I will note that my x86_64 bit machines uses: ../sysdeps/x86_64/multiarch/memcmp-ssse3.S and ../sysdeps/x86_64/multiarch/memcmp-sse4.S So it could be entirely a bug in your libc installed. -- Configure bugmail: http://bugzilla.gdcproject.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes. |
May 30, 2013 [Bug 57] Comparing small structs fails | ||||
---|---|---|---|---|
| ||||
http://bugzilla.gdcproject.org/show_bug.cgi?id=57 --- Comment #15 from Johannes Pfau <johannespfau@gmail.com> 2013-05-30 19:43:08 UTC --- Strange. This same binary fails on two different machines, Fedora 17 & 18. But it works fine on a third machine with archlinux. Maybe it's caused by some additional security feature thing. But doesn't the asm output look bogus to you as well? If I generate the asm code using gdc -S, then change the two lines I mentioned in my last comment to use "movq" instead of "movl" it works on all machines. AFAICS the 'padding' hole of the value returned from funcA is not initialized when it's written to the stack in the main function. The only difference seems to be that for some reason on some machines the stack is initialized to zero but on Fedora it's not. But if you think this is not a valid bug / concern feel free to close this :-) -- Configure bugmail: http://bugzilla.gdcproject.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes. |
May 31, 2013 [Bug 57] Comparing small structs fails | ||||
---|---|---|---|---|
| ||||
http://bugzilla.gdcproject.org/show_bug.cgi?id=57 --- Comment #16 from Iain Buclaw <ibuclaw@gdcproject.org> 2013-05-31 23:09:14 UTC --- Will probably keep open as this variant fails (and probably will on all x86_64 targets). --- struct S { int a; long b; //int pad; //doesn't happen for bigger structs } S funcA() { return S(4, 42); } void main() { S s = funcA(); assert (s is S(4, 42)); } -- Configure bugmail: http://bugzilla.gdcproject.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes. |
June 16, 2013 [Bug 57] Comparing small structs fails | ||||
---|---|---|---|---|
| ||||
http://bugzilla.gdcproject.org/show_bug.cgi?id=57 --- Comment #17 from Iain Buclaw <ibuclaw@gdcproject.org> 2013-06-16 17:00:24 UTC --- I have a "fix" for this. Just running it through the test suite... -- Configure bugmail: http://bugzilla.gdcproject.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes. |
June 17, 2013 [Bug 57] Comparing small structs fails | ||||
---|---|---|---|---|
| ||||
http://bugzilla.gdcproject.org/show_bug.cgi?id=57 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #18 from Iain Buclaw <ibuclaw@gdcproject.org> 2013-06-17 15:56:36 UTC --- https://github.com/D-Programming-GDC/GDC/commit/b860e116bfbb5216c811ae5966cf07f62ab56d87 -- Configure bugmail: http://bugzilla.gdcproject.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes. |
July 31, 2014 [Bug 57] Comparing small structs fails | ||||
---|---|---|---|---|
| ||||
Attachments:
| http://bugzilla.gdcproject.org/show_bug.cgi?id=57 Johannes Pfau <johannespfau@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |http://bugzilla.gdcproject. | |org/show_bug.cgi?id=147 -- You are receiving this mail because: You are watching all bug changes. |
Copyright © 1999-2021 by the D Language Foundation