-
-
Notifications
You must be signed in to change notification settings - Fork 619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stack corruption code gen bug with debug info #20898
Labels
Comments
I've gone ahead and disassembled it, and got a diff. It appears to be related to rm with*
dmd -g -of=without.exe main.d test.d
dmd -g -of=with.exe -version=MakeItWork main.d test.d
objdump -D -S without.obj > without.S
objdump -D -S with.obj > with.S
diff -p without.S with.S > delta.diff *** without.S 2025-02-19 16:56:03.425259600 +1300
--- with.S 2025-02-19 16:56:03.580244100 +1300
***************
*** 1,5 ****
! without.obj: file format pe-x86-64
Disassembly of section .rdata:
--- 1,5 ----
! with.obj: file format pe-x86-64
Disassembly of section .rdata:
*************** Disassembly of section .text:
*** 1344,1370 ****
0000000000000000 <_D6sidero4base4path10networking11String_UTF86__dtorMFNbZv>:
0: 55 push %rbp
1: 48 8b ec mov %rsp,%rbp
! 4: 48 89 4d 10 mov %rcx,0x10(%rbp)
! 8: 48 8b 4d 10 mov 0x10(%rbp),%rcx
! c: 48 83 ec 20 sub $0x20,%rsp
! 10: e8 00 00 00 00 call 15 <_D6sidero4base4path10networking11String_UTF86__dtorMFNbZv+0x15>
! 15: 48 83 c4 20 add $0x20,%rsp
! 19: 84 c0 test %al,%al
! 1b: 5d pop %rbp
! 1c: c3 ret
Disassembly of section .xdata:
0000000000000000 <$unwind$_D6sidero4base4path10networking11String_UTF86__dtorMFNbZv>:
! 0: 01 08 add %ecx,(%rax)
! 2: 02 05 04 03 01 50 add 0x50010304(%rip),%al # 5001030c <_D6sidero4base4path10networking12__ModuleInfoZ+0x500102fc>
Disassembly of section .pdata:
0000000000000000 <$pdata$_D6sidero4base4path10networking11String_UTF86__dtorMFNbZv>:
0: 00 00 add %al,(%rax)
2: 00 00 add %al,(%rax)
! 4: 1d 00 00 00 00 sbb $0x0,%eax
9: 00 00 add %al,(%rax)
...
--- 1344,1376 ----
0000000000000000 <_D6sidero4base4path10networking11String_UTF86__dtorMFNbZv>:
0: 55 push %rbp
1: 48 8b ec mov %rsp,%rbp
! 4: 48 83 ec 10 sub $0x10,%rsp
! 8: 48 89 4d 10 mov %rcx,0x10(%rbp)
! c: 48 8b 4d 10 mov 0x10(%rbp),%rcx
! 10: 48 83 ec 20 sub $0x20,%rsp
! 14: e8 00 00 00 00 call 19 <_D6sidero4base4path10networking11String_UTF86__dtorMFNbZv+0x19>
! 19: 48 83 c4 20 add $0x20,%rsp
! 1d: 84 c0 test %al,%al
! 1f: 74 08 je 29 <_D6sidero4base4path10networking11String_UTF86__dtorMFNbZv+0x29>
! 21: 48 c7 45 f8 00 00 00 movq $0x0,-0x8(%rbp)
! 28: 00
! 29: 48 8b e5 mov %rbp,%rsp
! 2c: 5d pop %rbp
! 2d: c3 ret
Disassembly of section .xdata:
0000000000000000 <$unwind$_D6sidero4base4path10networking11String_UTF86__dtorMFNbZv>:
! 0: 01 0c 02 add %ecx,(%rdx,%rax,1)
! 3: 05 04 03 01 50 add $0x50010304,%eax
Disassembly of section .pdata:
0000000000000000 <$pdata$_D6sidero4base4path10networking11String_UTF86__dtorMFNbZv>:
0: 00 00 add %al,(%rax)
2: 00 00 add %al,(%rax)
! 4: 2e 00 00 cs add %al,(%rax)
! 7: 00 00 add %al,(%rax)
9: 00 00 add %al,(%rax)
...
*************** Disassembly of section .debug$S:
*** 1610,1638 ****
2: 00 00 add %al,(%rax)
4: f1 int1
5: 00 00 add %al,(%rax)
! 7: 00 24 00 add %ah,(%rax,%rax,1)
! a: 00 00 add %al,(%rax)
! c: 12 00 adc (%rax),%al
! e: 01 11 add %edx,(%rcx)
! 10: 00 00 add %al,(%rax)
! 12: 00 00 add %al,(%rax)
! 14: 77 69 ja 7f <.debug$S+0x7f>
16: 74 68 je 80 <.debug$S+0x80>
! 18: 6f outsl %ds:(%rsi),(%dx)
! 19: 75 74 jne 8f <.debug$S+0x8f>
! 1b: 2e 6f outsl %ds:(%rsi),(%dx)
! 1d: 62 (bad)
! 1e: 6a 00 push $0x0
! 20: 0e (bad)
! 21: 00 01 add %al,(%rcx)
! 23: 00 d0 add %dl,%al
! 25: 44 00 08 add %r9b,(%rax)
! 28: 07 (bad)
! 29: 5a pop %rdx
! 2a: 39 2e cmp %ebp,(%rsi)
! 2c: 30 30 xor %dh,(%rax)
! 2e: 2e 30 f3 cs xor %dh,%bl
! 31: 00 00 add %al,(%rax)
33: 00 2d 01 00 00 00 add %ch,0x1(%rip) # 3a <.debug$S+0x3a>
39: 50 push %rax
3a: 3a 5c 50 72 cmp 0x72(%rax,%rdx,2),%bl
--- 1616,1643 ----
2: 00 00 add %al,(%rax)
4: f1 int1
5: 00 00 add %al,(%rax)
! 7: 00 21 add %ah,(%rcx)
! 9: 00 00 add %al,(%rax)
! b: 00 0f add %cl,(%rdi)
! d: 00 01 add %al,(%rcx)
! f: 11 00 adc %eax,(%rax)
! 11: 00 00 add %al,(%rax)
! 13: 00 77 69 add %dh,0x69(%rdi)
16: 74 68 je 80 <.debug$S+0x80>
! 18: 2e 6f outsl %ds:(%rsi),(%dx)
! 1a: 62 (bad)
! 1b: 6a 00 push $0x0
! 1d: 0e (bad)
! 1e: 00 01 add %al,(%rcx)
! 20: 00 d0 add %dl,%al
! 22: 44 00 08 add %r9b,(%rax)
! 25: 07 (bad)
! 26: 5a pop %rdx
! 27: 39 2e cmp %ebp,(%rsi)
! 29: 30 30 xor %dh,(%rax)
! 2b: 2e 30 00 cs xor %al,(%rax)
! 2e: 00 00 add %al,(%rax)
! 30: f3 00 00 repz add %al,(%rax)
33: 00 2d 01 00 00 00 add %ch,0x1(%rip) # 3a <.debug$S+0x3a>
39: 50 push %rax
3a: 3a 5c 50 72 cmp 0x72(%rax,%rdx,2),%bl
*************** Disassembly of section .debug$S:
*** 3801,3860 ****
0: 04 00 add $0x0,%al
2: 00 00 add %al,(%rax)
4: f2 00 00 repnz add %al,(%rax)
! 7: 00 30 add %dh,(%rax)
...
11: 00 00 add %al,(%rax)
! 13: 00 1d 00 00 00 18 add %bl,0x18000000(%rip) # 18000019 <_D6sidero4base4path10networking12__ModuleInfoZ+0x18000009>
19: 00 00 add %al,(%rax)
! 1b: 00 03 add %al,(%rbx)
! 1d: 00 00 add %al,(%rax)
! 1f: 00 24 00 add %ah,(%rax,%rax,1)
22: 00 00 add %al,(%rax)
24: 00 00 add %al,(%rax)
26: 00 00 add %al,(%rax)
28: 3e 00 00 ds add %al,(%rax)
! 2b: 80 08 00 orb $0x0,(%rax)
! 2e: 00 00 add %al,(%rax)
! 30: 40 00 00 rex add %al,(%rax)
! 33: 80 1b 00 sbbb $0x0,(%rbx)
! 36: 00 00 add %al,(%rax)
! 38: 42 00 00 rex.X add %al,(%rax)
! 3b: 80 f1 00 xor $0x0,%cl
3e: 00 00 add %al,(%rax)
! 40: 6c insb (%dx),%es:(%rdi)
! 41: 00 00 add %al,(%rax)
! 43: 00 53 00 add %dl,0x0(%rbx)
! 46: 10 11 adc %dl,(%rcx)
...
! 54: 1d 00 00 00 08 sbb $0x8000000,%eax
! 59: 00 00 add %al,(%rax)
! 5b: 00 1b add %bl,(%rbx)
! 5d: 00 00 add %al,(%rax)
! 5f: 00 6a 10 add %ch,0x10(%rdx)
...
- 6a: 00 73 69 add %dh,0x69(%rbx)
- 6d: 64 65 72 6f fs gs jb e0 <_D6sidero4base4path10networking12__ModuleInfoZ+0xd0>
- 71: 2e 62 61 cs (bad)
- 74: 73 65 jae db <_D6sidero4base4path10networking12__ModuleInfoZ+0xcb>
- 76: 2e 70 61 jo,pn da <_D6sidero4base4path10networking12__ModuleInfoZ+0xca>
- 79: 74 68 je e3 <_D6sidero4base4path10networking12__ModuleInfoZ+0xd3>
- 7b: 2e 6e outsb %ds:(%rsi),(%dx)
- 7d: 65 74 77 gs je f7 <_D6sidero4base4path10networking12__ModuleInfoZ+0xe7>
- 80: 6f outsl %ds:(%rsi),(%dx)
- 81: 72 6b jb ee <_D6sidero4base4path10networking12__ModuleInfoZ+0xde>
- 83: 69 6e 67 2e 53 74 72 imul $0x7274532e,0x67(%rsi),%ebp
- 8a: 69 6e 67 5f 55 54 46 imul $0x4654555f,0x67(%rsi),%ebp
- 91: 38 2e cmp %ch,(%rsi)
- 93: 7e 74 jle 109 <_D6sidero4base4path10networking12__ModuleInfoZ+0xf9>
- 95: 68 69 73 00 11 push $0x11007369
- 9a: 00 11 add %dl,(%rcx)
- 9c: 11 10 adc %edx,(%rax)
- 9e: 00 00 add %al,(%rax)
- a0: 00 36 add %dh,(%rsi)
- a2: 10 00 adc %al,(%rax)
- a4: 00 4e 01 add %cl,0x1(%rsi)
- a7: 74 68 je 111 <_D6sidero4base4path10networking12__ModuleInfoZ+0x101>
- a9: 69 73 00 02 00 06 00 imul $0x60002,0x0(%rbx),%esi
Disassembly of section .debug$S:
--- 3806,3880 ----
0: 04 00 add $0x0,%al
2: 00 00 add %al,(%rax)
4: f2 00 00 repnz add %al,(%rax)
! 7: 00 38 add %bh,(%rax)
...
11: 00 00 add %al,(%rax)
! 13: 00 2e add %ch,(%rsi)
! 15: 00 00 add %al,(%rax)
! 17: 00 18 add %bl,(%rax)
19: 00 00 add %al,(%rax)
! 1b: 00 04 00 add %al,(%rax,%rax,1)
! 1e: 00 00 add %al,(%rax)
! 20: 2c 00 sub $0x0,%al
22: 00 00 add %al,(%rax)
24: 00 00 add %al,(%rax)
26: 00 00 add %al,(%rax)
28: 3e 00 00 ds add %al,(%rax)
! 2b: 80 0c 00 00 orb $0x0,(%rax,%rax,1)
! 2f: 00 40 00 add %al,0x0(%rax)
! 32: 00 80 21 00 00 00 add %al,0x21(%rax)
! 38: 41 00 00 add %al,(%r8)
! 3b: 80 29 00 subb $0x0,(%rcx)
3e: 00 00 add %al,(%rax)
! 40: 42 00 00 rex.X add %al,(%rax)
! 43: 80 f1 00 xor $0x0,%cl
! 46: 00 00 add %al,(%rax)
! 48: 80 00 00 addb $0x0,(%rax)
! 4b: 00 53 00 add %dl,0x0(%rbx)
! 4e: 10 11 adc %dl,(%rcx)
...
! 5c: 2e 00 00 cs add %al,(%rax)
! 5f: 00 0c 00 add %cl,(%rax,%rax,1)
! 62: 00 00 add %al,(%rax)
! 64: 29 00 sub %eax,(%rax)
! 66: 00 00 add %al,(%rax)
! 68: 6a 10 push $0x10
! ...
! 72: 00 73 69 add %dh,0x69(%rbx)
! 75: 64 65 72 6f fs gs jb e8 <_D6sidero4base4path10networking12__ModuleInfoZ+0xd8>
! 79: 2e 62 61 cs (bad)
! 7c: 73 65 jae e3 <_D6sidero4base4path10networking12__ModuleInfoZ+0xd3>
! 7e: 2e 70 61 jo,pn e2 <_D6sidero4base4path10networking12__ModuleInfoZ+0xd2>
! 81: 74 68 je eb <_D6sidero4base4path10networking12__ModuleInfoZ+0xdb>
! 83: 2e 6e outsb %ds:(%rsi),(%dx)
! 85: 65 74 77 gs je ff <_D6sidero4base4path10networking12__ModuleInfoZ+0xef>
! 88: 6f outsl %ds:(%rsi),(%dx)
! 89: 72 6b jb f6 <_D6sidero4base4path10networking12__ModuleInfoZ+0xe6>
! 8b: 69 6e 67 2e 53 74 72 imul $0x7274532e,0x67(%rsi),%ebp
! 92: 69 6e 67 5f 55 54 46 imul $0x4654555f,0x67(%rsi),%ebp
! 99: 38 2e cmp %ch,(%rsi)
! 9b: 7e 74 jle 111 <_D6sidero4base4path10networking12__ModuleInfoZ+0x101>
! 9d: 68 69 73 00 11 push $0x11007369
! a2: 00 11 add %dl,(%rcx)
! a4: 11 10 adc %edx,(%rax)
! a6: 00 00 add %al,(%rax)
! a8: 00 36 add %dh,(%rsi)
! aa: 10 00 adc %al,(%rax)
! ac: 00 4e 01 add %cl,0x1(%rsi)
! af: 74 68 je 119 <_D6sidero4base4path10networking12__ModuleInfoZ+0x109>
! b1: 69 73 00 02 00 0a 00 imul $0xa0002,0x0(%rbx),%esi
! b8: 0e (bad)
! b9: 00 11 add %dl,(%rcx)
! bb: 11 f8 adc %edi,%eax
! bd: ff (bad)
! be: ff (bad)
! bf: ff 23 jmp *(%rbx)
! c1: 00 00 add %al,(%rax)
! c3: 00 4e 01 add %cl,0x1(%rsi)
! c6: 5f pop %rdi
! c7: 00 02 add %al,(%rdx)
! c9: 00 06 add %al,(%rsi)
...
Disassembly of section .debug$S: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
According to run.dlang.io it worked in 2.100.2 of dmd, but not 2.101.2. Ldc has consistently worked correctly.
The test module:
While you can join them, I suggest keeping them separate, the behaviour is consistent that way.
Test procedure (
-i
should not be required):The second will work, the first will not.
As a bug I have had this in my codebase for over a year, but because it is hard to minimize 6+mb of code (almost a week), I've been putting it off.
I have tried to minimize further, but all the code in
sidero.base.path.networking
seems to be essential to make it fail.The text was updated successfully, but these errors were encountered: