go 运行时:make.bat挂起

sg3maiej  于 4个月前  发布在  Go
关注(0)|答案(8)|浏览(51)

我有一个Windows 7电脑,系统是windows/amd64。
我正在使用go1.4从源代码构建Go。
我使用的是56d6b87的提交。
我正在运行make.bat命令。

你期望看到什么?

我期望make.bat命令能够成功完成。

你看到了什么?

make.bat从未完成。它挂起,例如,像这样:

c:\Users\alexb\dev\go\src>make
Building Go cmd/dist using c:\users\alexb\dev\\go1.4
Building Go toolchain1 using c:\users\alexb\dev\\go1.4.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.

我使用了process explorer https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer来检查进程树,这就是我看到的:

我还使用了WinDbg来附加到go_bootstrap.exe(pid 9788)并打印其所有线程的堆栈。这就是我看到的:

0:019> !uniqstack
Processing 20 threads, please wait

.  0  Id: 263c.23d8 Suspend: 1 Teb: 000007ff`fffde000 Unfrozen
      Start: go_bootstrap+0x648e0 (00000000`004648e0) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`0022fae8 000007fe`fcc710ac ntdll!ZwWaitForSingleObject+0xa
00000000`0022faf0 00000000`0046494e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`0022fb90 00000000`00b37be0 go_bootstrap+0x6494e
00000000`0022fb98 00000000`004270d3 go_bootstrap+0x737be0
00000000`0022fba0 00000000`00000000 go_bootstrap+0x270d3

.  1  Id: 263c.314c Suspend: 1 Teb: 000007ff`fffdc000 Unfrozen
      Start: tmmon64+0x8adac (00000000`7478adac) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`0302fcb8 000007fe`fcc71430 ntdll!ZwWaitForMultipleObjects+0xa
00000000`0302fcc0 00000000`76df06c0 KERNELBASE!GetCurrentProcess+0x40
00000000`0302fdc0 00000000`747aeed4 kernel32!WaitForMultipleObjects+0xb0
00000000`0302fe50 00000000`7478ad07 tmmon64+0xaeed4
00000000`0302ff00 00000000`7478aeae tmmon64+0x8ad07
00000000`0302ff30 00000000`76df59cd tmmon64+0x8aeae
00000000`0302ff60 00000000`76f2a561 kernel32!BaseThreadInitThunk+0xd
00000000`0302ff90 00000000`00000000 ntdll!RtlUserThreadStart+0x21

.  2  Id: 263c.2d5c Suspend: 1 Teb: 000007ff`fffda000 Unfrozen
      Start: ntdll!RtlDestroyHandleTable+0x270 (00000000`76f1f6f0) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`0322fcc8 00000000`76f1ed15 ntdll!ZwWaitForWorkViaWorkerFactory+0xa
00000000`0322fcd0 00000000`76df59cd ntdll!RtlValidateHeap+0x155
00000000`0322ff60 00000000`76f2a561 kernel32!BaseThreadInitThunk+0xd
00000000`0322ff90 00000000`00000000 ntdll!RtlUserThreadStart+0x21

.  3  Id: 263c.e74 Suspend: 1 Teb: 000007ff`fffd6000 Unfrozen
      Start: ntdll!TpIsTimerSet+0x8b0 (00000000`76f1a280) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`0342fcb8 00000000`76f1a3c7 ntdll!ZwWaitForMultipleObjects+0xa
00000000`0342fcc0 00000000`76df59cd ntdll!TpIsTimerSet+0x9f7
00000000`0342ff60 00000000`76f2a561 kernel32!BaseThreadInitThunk+0xd
00000000`0342ff90 00000000`00000000 ntdll!RtlUserThreadStart+0x21

.  4  Id: 263c.196c Suspend: 1 Teb: 000007ff`fffd4000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`28e5eb68 00000000`76f48f58 ntdll!ZwWaitForSingleObject+0xa
00000000`28e5eb70 00000000`76f48e54 ntdll!RtlDeNormalizeProcessParams+0x5a8
00000000`28e5ec20 000007fe`fa3b7f0b ntdll!RtlDeNormalizeProcessParams+0x4a4
00000000`28e5ec50 000007fe`fa3b8504 TmUmEvt64+0x17f0b
00000000`28e5eeb0 000007fe`fa3b8c96 TmUmEvt64+0x18504
00000000`28e5ef10 000007fe`fa4565ca TmUmEvt64+0x18c96
00000000`28e5efa0 000007fe`fa455f8e TmUmEvt64+0xb65ca
00000000`28e5f000 000007fe`fa410686 TmUmEvt64+0xb5f8e
00000000`28e5f150 000007fe`fa439730 TmUmEvt64+0x70686
00000000`28e5f260 00000000`7472f146 TmUmEvt64+0x99730
00000000`28e5f4a0 00000000`747e2d7d tmmon64+0x2f146
00000000`28e5f580 00000000`747e29f4 tmmon64+0xe2d7d
00000000`28e5f640 00000000`74733748 tmmon64+0xe29f4
00000000`28e5f6b0 000007fe`fcc77c3f tmmon64+0x33748
00000000`28e5f780 00000000`0046494e KERNELBASE!ResumeThread+0xf
00000000`28e5f7b0 ffffffff`ffffffff go_bootstrap+0x6494e
00000000`28e5f7b8 00000000`00000001 0xffffffff`ffffffff
00000000`28e5f7c0 ffffffff`ffffffff 0x1
00000000`28e5f7c8 00000000`28e5f928 0xffffffff`ffffffff
00000000`28e5f7d0 00000000`00000000 0x28e5f928

.  5  Id: 263c.3204 Suspend: 1 Teb: 000007ff`fffae000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2905fb08 000007fe`fcc710ac ntdll!ZwWaitForSingleObject+0xa
00000000`2905fb10 00000000`0046494e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`2905fbb0 000000c0`0002c980 go_bootstrap+0x6494e
00000000`2905fbb8 00000000`00000000 0xc0`0002c980

.  6  Id: 263c.32f0 Suspend: 1 Teb: 000007ff`fffac000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2925fb08 000007fe`fcc710ac ntdll!ZwWaitForSingleObject+0xa
00000000`2925fb10 00000000`0046494e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`2925fbb0 000000c0`0002cd00 go_bootstrap+0x6494e
00000000`2925fbb8 00000000`00000164 0xc0`0002cd00
00000000`2925fbc0 7fffffff`00000000 0x164
00000000`2925fbc8 00000000`00000160 0x7fffffff`00000000
00000000`2925fbd0 000000c0`004c6300 0x160
00000000`2925fbd8 00000000`2925fcc0 0xc0`004c6300
00000000`2925fbe0 00000000`0043daa2 0x2925fcc0
00000000`2925fbe8 00000000`00b36bf8 go_bootstrap+0x3daa2
00000000`2925fbf0 00000000`00000000 go_bootstrap+0x736bf8

.  7  Id: 263c.29d8 Suspend: 1 Teb: 000007ff`fffaa000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2945fb08 000007fe`fcc710ac ntdll!ZwWaitForSingleObject+0xa
00000000`2945fb10 00000000`0046494e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`2945fbb0 000000c0`00080280 go_bootstrap+0x6494e
00000000`2945fbb8 00000000`00000000 0xc0`00080280

.  8  Id: 263c.104c Suspend: 1 Teb: 000007ff`fffa8000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`29a8fb08 000007fe`fcc710ac ntdll!ZwWaitForSingleObject+0xa
00000000`29a8fb10 00000000`0046494e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`29a8fbb0 000000c0`00206280 go_bootstrap+0x6494e
00000000`29a8fbb8 00000000`00000000 0xc0`00206280

.  9  Id: 263c.31b4 Suspend: 1 Teb: 000007ff`fffa6000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`29ccfb08 000007fe`fcc710ac ntdll!ZwWaitForSingleObject+0xa
00000000`29ccfb10 00000000`0046494e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`29ccfbb0 000000c0`00207080 go_bootstrap+0x6494e
00000000`29ccfbb8 00000000`00000000 0xc0`00207080

. 10  Id: 263c.2b14 Suspend: 1 Teb: 000007ff`fffa4000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`29eceb68 00000000`76f48f58 ntdll!ZwWaitForSingleObject+0xa
00000000`29eceb70 00000000`76f48e54 ntdll!RtlDeNormalizeProcessParams+0x5a8
00000000`29ecec20 000007fe`fa3b7f0b ntdll!RtlDeNormalizeProcessParams+0x4a4
00000000`29ecec50 000007fe`fa3b8504 TmUmEvt64+0x17f0b
00000000`29eceeb0 000007fe`fa3b8c96 TmUmEvt64+0x18504
00000000`29ecef10 000007fe`fa4565ca TmUmEvt64+0x18c96
00000000`29ecefa0 000007fe`fa455f8e TmUmEvt64+0xb65ca
00000000`29ecf000 000007fe`fa410686 TmUmEvt64+0xb5f8e
00000000`29ecf150 000007fe`fa439730 TmUmEvt64+0x70686
00000000`29ecf260 00000000`7472f146 TmUmEvt64+0x99730
00000000`29ecf4a0 00000000`747e2d7d tmmon64+0x2f146
00000000`29ecf580 00000000`747e29f4 tmmon64+0xe2d7d
00000000`29ecf640 00000000`74733748 tmmon64+0xe29f4
00000000`29ecf6b0 000007fe`fcc77c3f tmmon64+0x33748
00000000`29ecf780 00000000`0046494e KERNELBASE!ResumeThread+0xf
00000000`29ecf7b0 ffffffff`ffffffff go_bootstrap+0x6494e
00000000`29ecf7b8 00000000`00000000 0xffffffff`ffffffff

. 11  Id: 263c.30b4 Suspend: 1 Teb: 000007ff`fffa2000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2a10fb08 000007fe`fcc710ac ntdll!ZwWaitForSingleObject+0xa
00000000`2a10fb10 00000000`0046494e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`2a10fbb0 000000c0`00195400 go_bootstrap+0x6494e
00000000`2a10fbb8 00000000`00000009 0xc0`00195400
00000000`2a10fbc0 00000000`00000000 0x9

. 12  Id: 263c.30fc Suspend: 1 Teb: 000007ff`fffa0000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2a30f248 00000000`76f48f58 ntdll!ZwWaitForSingleObject+0xa
00000000`2a30f250 00000000`76f48e54 ntdll!RtlDeNormalizeProcessParams+0x5a8
00000000`2a30f300 000007fe`fa3b7f0b ntdll!RtlDeNormalizeProcessParams+0x4a4
00000000`2a30f330 000007fe`fa3b8504 TmUmEvt64+0x17f0b
00000000`2a30f590 000007fe`fa3b8c96 TmUmEvt64+0x18504
00000000`2a30f5f0 000007fe`fa4565ca TmUmEvt64+0x18c96
00000000`2a30f680 000007fe`fa455f8e TmUmEvt64+0xb65ca
00000000`2a30f6e0 000007fe`fa410686 TmUmEvt64+0xb5f8e
00000000`2a30f830 000007fe`fa4363b0 TmUmEvt64+0x70686
00000000`2a30f940 00000000`7472f146 TmUmEvt64+0x963b0
00000000`2a30fb80 00000000`747e2d7d tmmon64+0x2f146
00000000`2a30fc60 00000000`747e29f4 tmmon64+0xe2d7d
00000000`2a30fd20 00000000`74732869 tmmon64+0xe29f4
00000000`2a30fd90 00000000`0046494e tmmon64+0x32869
00000000`2a30fe60 000000c0`00306100 go_bootstrap+0x6494e
00000000`2a30fe68 000000c0`0016b840 0xc0`00306100
00000000`2a30fe70 00000000`2a30fe60 0xc0`0016b840
00000000`2a30fe78 00000000`00000000 0x2a30fe60

. 13  Id: 263c.13a0 Suspend: 2 Teb: 000007ff`fff9e000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2a50ec50 000007fe`fa3b8504 TmUmEvt64+0x17fa0
00000000`2a50eeb0 000007fe`fa3b8c96 TmUmEvt64+0x18504
00000000`2a50ef10 000007fe`fa4565ca TmUmEvt64+0x18c96
00000000`2a50efa0 000007fe`fa455f8e TmUmEvt64+0xb65ca
00000000`2a50f000 000007fe`fa410686 TmUmEvt64+0xb5f8e
00000000`2a50f150 000007fe`fa439730 TmUmEvt64+0x70686
00000000`2a50f260 00000000`7472f146 TmUmEvt64+0x99730
00000000`2a50f4a0 00000000`747e2d7d tmmon64+0x2f146
00000000`2a50f580 00000000`747e29f4 tmmon64+0xe2d7d
00000000`2a50f640 00000000`74733748 tmmon64+0xe29f4
00000000`2a50f6b0 000007fe`fcc77c3f tmmon64+0x33748
00000000`2a50f780 00000000`0046494e KERNELBASE!ResumeThread+0xf
00000000`2a50f7b0 ffffffff`ffffffff go_bootstrap+0x6494e
00000000`2a50f7b8 00000000`00000000 0xffffffff`ffffffff

. 15  Id: 263c.1c34 Suspend: 1 Teb: 000007ff`fff9a000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2a90faf8 000007fe`fcc710ac ntdll!ZwWaitForSingleObject+0xa
00000000`2a90fb00 00000000`0046494e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`2a90fba0 000000c0`003b9400 go_bootstrap+0x6494e
00000000`2a90fba8 ffffffff`fff85ee0 0xc0`003b9400
00000000`2a90fbb0 00000000`00000000 0xffffffff`fff85ee0

. 16  Id: 263c.2530 Suspend: 1 Teb: 000007ff`fff98000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2ab0fb08 000007fe`fcc710ac ntdll!ZwWaitForSingleObject+0xa
00000000`2ab0fb10 00000000`0046494e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`2ab0fbb0 000000c0`003b9780 go_bootstrap+0x6494e
00000000`2ab0fbb8 00000000`00000009 0xc0`003b9780
00000000`2ab0fbc0 00000000`00000000 0x9

. 17  Id: 263c.3114 Suspend: 1 Teb: 000007ff`fff96000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2ad0fb08 000007fe`fcc710ac ntdll!ZwWaitForSingleObject+0xa
00000000`2ad0fb10 00000000`0046494e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`2ad0fbb0 000000c0`00508d00 go_bootstrap+0x6494e
00000000`2ad0fbb8 00000000`00000000 0xc0`00508d00

. 18  Id: 263c.3344 Suspend: 3 Teb: 000007ff`fff94000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2af0fb08 000007fe`fcc71430 ntdll!ZwWaitForMultipleObjects+0xa
00000000`2af0fb10 00000000`76df06c0 KERNELBASE!GetCurrentProcess+0x40
00000000`2af0fc10 00000000`0046494e kernel32!WaitForMultipleObjects+0xb0
00000000`2af0fca0 000007ff`fff94000 go_bootstrap+0x6494e
00000000`2af0fca8 00000000`00000000 0x7ff`fff94000

. 19  Id: 263c.3128 Suspend: 1 Teb: 000007ff`fff92000 Unfrozen
      Start: ntdll!DbgUiRemoteBreakin (00000000`76ff2dd0) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2b10ff28 00000000`76ff2e08 ntdll!DbgBreakPoint
00000000`2b10ff30 00000000`76df59cd ntdll!DbgUiRemoteBreakin+0x38
00000000`2b10ff60 00000000`76f2a561 kernel32!BaseThreadInitThunk+0xd
00000000`2b10ff90 00000000`00000000 ntdll!RtlUserThreadStart+0x21

Total threads: 20
Duplicate callstacks: 1 (windbg thread #s follow):
14

我曾经能够使用Delve一次来检查这个bug(参见#35775(评论)),但现在不行了。Delve现在只是无法附加。
我可以在特定的计算机上非常可靠地重现这个问题——make.bat从未完成。有时它会在go_bootstrap.exe中挂起,有时会在compile.exe中挂起。有时有多个挂起的compile.exe。
如果我将源代码更改为将runtime.preemptMSupported设置为false,我就可以解决这个问题。

dhxwm5r4

dhxwm5r41#

感谢您的详细报告。

大部分线程看起来都不太有趣,除了我认为以下两个:

.  4  Id: 263c.196c Suspend: 1 Teb: 000007ff`fffd4000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`28e5eb68 00000000`76f48f58 ntdll!ZwWaitForSingleObject+0xa
00000000`28e5eb70 00000000`76f48e54 ntdll!RtlDeNormalizeProcessParams+0x5a8
00000000`28e5ec20 000007fe`fa3b7f0b ntdll!RtlDeNormalizeProcessParams+0x4a4
00000000`28e5ec50 000007fe`fa3b8504 TmUmEvt64+0x17f0b
00000000`28e5eeb0 000007fe`fa3b8c96 TmUmEvt64+0x18504
00000000`28e5ef10 000007fe`fa4565ca TmUmEvt64+0x18c96
00000000`28e5efa0 000007fe`fa455f8e TmUmEvt64+0xb65ca
00000000`28e5f000 000007fe`fa410686 TmUmEvt64+0xb5f8e
00000000`28e5f150 000007fe`fa439730 TmUmEvt64+0x70686
00000000`28e5f260 00000000`7472f146 TmUmEvt64+0x99730
00000000`28e5f4a0 00000000`747e2d7d tmmon64+0x2f146
00000000`28e5f580 00000000`747e29f4 tmmon64+0xe2d7d
00000000`28e5f640 00000000`74733748 tmmon64+0xe29f4
00000000`28e5f6b0 000007fe`fcc77c3f tmmon64+0x33748
00000000`28e5f780 00000000`0046494e KERNELBASE!ResumeThread+0xf
00000000`28e5f7b0 ffffffff`ffffffff go_bootstrap+0x6494e
00000000`28e5f7b8 00000000`00000001 0xffffffff`ffffffff
00000000`28e5f7c0 ffffffff`ffffffff 0x1
00000000`28e5f7c8 00000000`28e5f928 0xffffffff`ffffffff
00000000`28e5f7d0 00000000`00000000 0x28e5f928

. 10  Id: 263c.2b14 Suspend: 1 Teb: 000007ff`fffa4000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`29eceb68 00000000`76f48f58 ntdll!ZwWaitForSingleObject+0xa
00000000`29eceb70 00000000`76f48e54 ntdll!RtlDeNormalizeProcessParams+0x5a8
00000000`29ecec20 000007fe`fa3b7f0b ntdll!RtlDeNormalizeProcessParams+0x4a4
00000000`29ecec50 000007fe`fa3b8504 TmUmEvt64+0x17f0b
00000000`29eceeb0 000007fe`fa3b8c96 TmUmEvt64+0x18504
00000000`29ecef10 000007fe`fa4565ca TmUmEvt64+0x18c96
00000000`29ecefa0 000007fe`fa455f8e TmUmEvt64+0xb65ca
00000000`29ecf000 000007fe`fa410686 TmUmEvt64+0xb5f8e
00000000`29ecf150 000007fe`fa439730 TmUmEvt64+0x70686
00000000`29ecf260 00000000`7472f146 TmUmEvt64+0x99730
00000000`29ecf4a0 00000000`747e2d7d tmmon64+0x2f146
00000000`29ecf580 00000000`747e29f4 tmmon64+0xe2d7d
00000000`29ecf640 00000000`74733748 tmmon64+0xe29f4
00000000`29ecf6b0 000007fe`fcc77c3f tmmon64+0x33748
00000000`29ecf780 00000000`0046494e KERNELBASE!ResumeThread+0xf
00000000`29ecf7b0 ffffffff`ffffffff go_bootstrap+0x6494e
00000000`29ecf7b8 00000000`00000000 0xffffffff`ffffffff

. 13  Id: 263c.13a0 Suspend: 2 Teb: 000007ff`fff9e000 Unfrozen
      Start: go_bootstrap+0x64d00 (00000000`00464d00) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2a50ec50 000007fe`fa3b8504 TmUmEvt64+0x17fa0
00000000`2a50eeb0 000007fe`fa3b8c96 TmUmEvt64+0x18504
00000000`2a50ef10 000007fe`fa4565ca TmUmEvt64+0x18c96
00000000`2a50efa0 000007fe`fa455f8e TmUmEvt64+0xb65ca
00000000`2a50f000 000007fe`fa410686 TmUmEvt64+0xb5f8e
00000000`2a50f150 000007fe`fa439730 TmUmEvt64+0x70686
00000000`2a50f260 00000000`7472f146 TmUmEvt64+0x99730
00000000`2a50f4a0 00000000`747e2d7d tmmon64+0x2f146
00000000`2a50f580 00000000`747e29f4 tmmon64+0xe2d7d
00000000`2a50f640 00000000`74733748 tmmon64+0xe29f4
00000000`2a50f6b0 000007fe`fcc77c3f tmmon64+0x33748
00000000`2a50f780 00000000`0046494e KERNELBASE!ResumeThread+0xf
00000000`2a50f7b0 ffffffff`ffffffff go_bootstrap+0x6494e
00000000`2a50f7b8 00000000`00000000 0xffffffff`ffffffff

这些线程都卡在了 ResumeThread 中,我不知道线程竟然会卡住。
线程13也很有趣,因为“挂起计数”是2,这表明某个其他线程已经挂起它,并且无法恢复它。这也可能是我们为什么知道线程4和10在明显阻塞的操作中停止,而线程13在看似随机的地方停止的原因。
您知道“tmmon64”和“TmUmEvt64”是什么吗?
也许我们只需要长时间持有挂起锁(尽管我没有理论说明为什么这会是这样)。如果将 unlock(&suspendLock)preemptM 移动到函数的底部会发生什么?

ebdffaop

ebdffaop2#

你知道 "tmmon64" 和 "TmUmEvt64" 是什么吗?
这不是我的电脑,所以我不能正确地操作它。但我怀疑这台电脑上安装了一些标准的病毒软件。这类软件通常会将它们的代码安装到拦截真实的 Win32 API 调用中。
也许我们只需要延长 suspendLock 的时间(尽管我不知道为什么这会有用)。如果你把 unlock(&suspendLock)preemptM 移动到函数的底部会发生什么?
周末我见不到她。但我会在周一或周二尝试一下。请也显示你建议更改的差异,因为我不信任自己能读懂你的心思。
谢谢。
Alex

sczxawaw

sczxawaw3#

也许我们需要让suspendLock保持更长的时间(尽管我没有理论说明为什么这会是这样)。如果你把unlock(&suspendLock)移动到preemptM的底部会发生什么?
我修改了代码,如下所示:

diff --git a/src/runtime/os_windows.go b/src/runtime/os_windows.go
index 91e147fca9..9166aeb323 100644
--- a/src/runtime/os_windows.go
+++ b/src/runtime/os_windows.go
@@ -1201,8 +1201,6 @@ func preemptM(mp *m) {
        // GetThreadContext actually blocks until it's suspended.
        stdcall2(_GetThreadContext, thread, uintptr(unsafe.Pointer(c)))

-       unlock(&suspendLock)
-
        // Does it want a preemption and is it safe to preempt?
        gp := gFromTLS(mp)
        if wantAsyncPreempt(gp) && isAsyncSafePoint(gp, c.ip(), c.sp(), c.lr())
{
@@ -1231,6 +1229,8 @@ func preemptM(mp *m) {

        stdcall1(_ResumeThread, thread)
        stdcall1(_CloseHandle, thread)
+
+       unlock(&suspendLock)
 }

 // osPreemptExtEnter is called before entering external code that may

我设法成功运行了一次make.bat。但然后它像以前一样挂起,当我第二次运行make.bat时。这一次,是compile.exe挂起了。这是来自windbg的堆栈跟踪信息:

0:009> !uniqstack
Processing 10 threads, please wait

.  0  Id: 2c08.3140 Suspend: 1 Teb: 000007ff`fffde000 Unfrozen
      Start: compile+0x67ef0 (00000000`00467ef0) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`0022fd98 000007fe`fcd610ac ntdll!ZwWaitForSingleObject+0xa
00000000`0022fda0 00000000`00467f5e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`0022fe40 00000000`0160d320 compile+0x67f5e
00000000`0022fe48 00000000`00000001 compile+0x120d320
00000000`0022fe50 00000000`00000000 0x1

.  1  Id: 2c08.243c Suspend: 1 Teb: 000007ff`fffdc000 Unfrozen
      Start: tmmon64+0x8adac (00000000`7480adac) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`03cdfcb8 000007fe`fcd61430 ntdll!ZwWaitForMultipleObjects+0xa
00000000`03cdfcc0 00000000`76d806c0 KERNELBASE!GetCurrentProcess+0x40
00000000`03cdfdc0 00000000`7482eed4 kernel32!WaitForMultipleObjects+0xb0
00000000`03cdfe50 00000000`7480ad07 tmmon64+0xaeed4
00000000`03cdff00 00000000`7480aeae tmmon64+0x8ad07
00000000`03cdff30 00000000`76d859cd tmmon64+0x8aeae
00000000`03cdff60 00000000`76fba561 kernel32!BaseThreadInitThunk+0xd
00000000`03cdff90 00000000`00000000 ntdll!RtlUserThreadStart+0x21

.  2  Id: 2c08.20ec Suspend: 1 Teb: 000007ff`fffda000 Unfrozen
      Start: ntdll!RtlDestroyHandleTable+0x270 (00000000`76faf6f0) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`03fefcc8 00000000`76faed15 ntdll!ZwWaitForWorkViaWorkerFactory+0xa
00000000`03fefcd0 00000000`76d859cd ntdll!RtlValidateHeap+0x155
00000000`03feff60 00000000`76fba561 kernel32!BaseThreadInitThunk+0xd
00000000`03feff90 00000000`00000000 ntdll!RtlUserThreadStart+0x21

.  3  Id: 2c08.2ecc Suspend: 1 Teb: 000007ff`fffd8000 Unfrozen
      Start: ntdll!TpIsTimerSet+0x8b0 (00000000`76faa280) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`041efcb8 00000000`76faa3c7 ntdll!ZwWaitForMultipleObjects+0xa
00000000`041efcc0 00000000`76d859cd ntdll!TpIsTimerSet+0x9f7
00000000`041eff60 00000000`76fba561 kernel32!BaseThreadInitThunk+0xd
00000000`041eff90 00000000`00000000 ntdll!RtlUserThreadStart+0x21

.  4  Id: 2c08.2cf4 Suspend: 1 Teb: 000007ff`fffd4000 Unfrozen
      Start: compile+0x68330 (00000000`00468330) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`299def98 00000000`76fd8f58 ntdll!ZwWaitForSingleObject+0xa
00000000`299defa0 00000000`76fd8e54 ntdll!RtlDeNormalizeProcessParams+0x5a8
00000000`299df050 00000000`76fde0b5 ntdll!RtlDeNormalizeProcessParams+0x4a4
00000000`299df080 00000000`76fdddd8 ntdll!RtlAllocateHeap+0x455
00000000`299df260 000007fe`fcd61635 ntdll!RtlAllocateHeap+0x178
00000000`299df370 000007fe`fa36bf7d KERNELBASE!LocalAlloc+0x75
00000000`299df3e0 000007fe`fa36c187 TmUmEvt64!TmmonDestoryAddonObject+0x63d
00000000`299df430 000007fe`fa36bbf1 TmUmEvt64!TmmonDestoryAddonObject+0x847
00000000`299df4b0 00000000`74862cd3 TmUmEvt64!TmmonDestoryAddonObject+0x2b1
00000000`299df580 00000000`748629f4 tmmon64+0xe2cd3
00000000`299df640 00000000`747b3de4 tmmon64+0xe29f4
00000000`299df6b0 00000000`76d72a4a tmmon64+0x33de4
00000000`299df780 00000000`00467f5e kernel32!GetThreadContext+0xa
00000000`299df7b0 ffffffff`ffffffff compile+0x67f5e
00000000`299df7b8 00000000`00000000 0xffffffff`ffffffff

.  5  Id: 2c08.ea4 Suspend: 1 Teb: 000007ff`fffae000 Unfrozen
      Start: compile+0x68330 (00000000`00468330) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`29bdfb08 000007fe`fcd610ac ntdll!ZwWaitForSingleObject+0xa
00000000`29bdfb10 00000000`00467f5e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`29bdfbb0 000000c0`0002c980 compile+0x67f5e
00000000`29bdfbb8 00000000`00000000 0xc0`0002c980

.  6  Id: 2c08.558 Suspend: 2 Teb: 000007ff`fffac000 Unfrozen
      Start: compile+0x68330 (00000000`00468330) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`29ddf530 00000000`76ffcf71 ntdll!RtlUnlockHeap+0x6a8
00000000`29ddf5c0 00000000`76fdddd8 ntdll!TpAlpcRegisterCompletionList+0xaf91
00000000`29ddf7a0 000007fe`fcd61635 ntdll!RtlAllocateHeap+0x178
00000000`29ddf8b0 000007fe`fa36bf7d KERNELBASE!LocalAlloc+0x75
00000000`29ddf920 000007fe`fa36c187 TmUmEvt64!TmmonDestoryAddonObject+0x63d
00000000`29ddf970 000007fe`fa36bbf1 TmUmEvt64!TmmonDestoryAddonObject+0x847
00000000`29ddf9f0 00000000`74862cd3 TmUmEvt64!TmmonDestoryAddonObject+0x2b1
00000000`29ddfac0 00000000`748629f4 tmmon64+0xe2cd3
00000000`29ddfb80 00000000`747b0aab tmmon64+0xe29f4
00000000`29ddfbf0 00000000`00467f5e tmmon64+0x30aab
00000000`29ddfcc0 000000c0`005c4000 compile+0x67f5e
00000000`29ddfcc8 00000000`00002000 0xc0`005c4000
00000000`29ddfcd0 00000000`00001000 0x2000
00000000`29ddfcd8 00000000`00000004 0x1000
00000000`29ddfce0 00000000`00432b66 0x4
00000000`29ddfce8 00000000`76d914cf compile+0x32b66
00000000`29ddfcf0 00000000`0000016c kernel32!GetTickCount+0x1f
00000000`29ddfcf8 00000000`ffffffff 0x16c
00000000`29ddfd00 00000000`00000000 0xffffffff

.  7  Id: 2c08.2f14 Suspend: 1 Teb: 000007ff`fffaa000 Unfrozen
      Start: compile+0x68330 (00000000`00468330) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2a01fb08 000007fe`fcd610ac ntdll!ZwWaitForSingleObject+0xa
00000000`2a01fb10 00000000`00467f5e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`2a01fbb0 000000c0`00080280 compile+0x67f5e
00000000`2a01fbb8 00000000`01e7b5c0 0xc0`00080280
00000000`2a01fbc0 00000000`00000000 0x1e7b5c0

.  8  Id: 2c08.2f64 Suspend: 1 Teb: 000007ff`fffa8000 Unfrozen
      Start: ntdll!RtlDestroyHandleTable+0x270 (00000000`76faf6f0) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2a68f3a8 00000000`76fd8f58 ntdll!ZwWaitForSingleObject+0xa
00000000`2a68f3b0 00000000`76fd8e54 ntdll!RtlDeNormalizeProcessParams+0x5a8
00000000`2a68f460 00000000`76fde0b5 ntdll!RtlDeNormalizeProcessParams+0x4a4
00000000`2a68f490 00000000`76fdddd8 ntdll!RtlAllocateHeap+0x455
00000000`2a68f670 00000000`76fba762 ntdll!RtlAllocateHeap+0x178
00000000`2a68f780 000007fe`fcd62898 ntdll!RtlUserThreadStart+0x222
00000000`2a68f7c0 000007fe`fa38ae5e KERNELBASE!FlsSetValue+0x168
00000000`2a68f7f0 000007fe`fa38a152 TmUmEvt64!GetInterface+0x1e50e
00000000`2a68f820 000007fe`fa389c2d TmUmEvt64!GetInterface+0x1d802
00000000`2a68f850 000007fe`fa385c19 TmUmEvt64!GetInterface+0x1d2dd
00000000`2a68f880 000007fe`fa385fc9 TmUmEvt64!GetInterface+0x192c9
00000000`2a68f8b0 000007fe`fa3861f9 TmUmEvt64!GetInterface+0x19679
00000000`2a68f8e0 00000000`76fba719 TmUmEvt64!GetInterface+0x198a9
00000000`2a68f940 00000000`76fba46f ntdll!RtlUserThreadStart+0x1d9
00000000`2a68fa40 00000000`76fba36e ntdll!LdrInitializeThunk+0x10f
00000000`2a68fab0 00000000`00000000 ntdll!LdrInitializeThunk+0xe

.  9  Id: 2c08.2b84 Suspend: 1 Teb: 000007ff`fffa6000 Unfrozen
      Start: ntdll!DbgUiRemoteBreakin (00000000`77082dd0) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2a88ff28 00000000`77082e08 ntdll!DbgBreakPoint
00000000`2a88ff30 00000000`76d859cd ntdll!DbgUiRemoteBreakin+0x38
00000000`2a88ff60 00000000`76fba561 kernel32!BaseThreadInitThunk+0xd
00000000`2a88ff90 00000000`00000000 ntdll!RtlUserThreadStart+0x21

Total threads: 10

Alex

jfewjypa

jfewjypa4#

我刚刚尝试验证这个问题,但在af9ab6b上仍然存在问题。它在这里卡住了

c:\Users\alexb\dev\go\src>make
Building Go cmd/dist using c:\users\alexb\dev\\go1.4
Building Go toolchain1 using c:\users\alexb\dev\\go1.4.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.

当卡住时,进程树的样子如下:

这是windbg关于pid为11956的compile.exe进程的信息:

Microsoft (R) Windows Debugger Version 6.12.0002.633 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.

*** wait with pending attach
Symbol search path is: *** Invalid ***
****************************************************************************
* Symbol loading may be unreliable without a symbol search path.           *
* Use .symfix to have the debugger choose a symbol path.                   *
* After setting your symbol path, use .reload to refresh symbol locations. *
****************************************************************************
Executable search path is: 
ModLoad: 00000000`00400000 00000000`0175a000   c:\Users\alexb\dev\go\pkg\tool\windows_amd64\compile.exe
ModLoad: 00000000`76fb0000 00000000`7715a000   C:\Windows\SYSTEM32\ntdll.dll
ModLoad: 00000000`76d90000 00000000`76eaf000   C:\Windows\system32\kernel32.dll
ModLoad: 000007fe`fce10000 000007fe`fce7a000   C:\Windows\system32\KERNELBASE.dll
ModLoad: 000007fe`fa450000 000007fe`fa622000   C:\Windows\system32\tmumh\20019\AddOn\8.50.0.2071\TmUmEvt64.dll
ModLoad: 00000000`77160000 00000000`77167000   C:\Windows\system32\PSAPI.DLL
ModLoad: 00000000`76eb0000 00000000`76faa000   C:\Windows\system32\USER32.dll
ModLoad: 000007fe`fd850000 000007fe`fd8b7000   C:\Windows\system32\GDI32.dll
ModLoad: 000007fe`fee80000 000007fe`fee8e000   C:\Windows\system32\LPK.dll
ModLoad: 000007fe`fefa0000 000007fe`ff06b000   C:\Windows\system32\USP10.dll
ModLoad: 000007fe`fee90000 000007fe`fef2f000   C:\Windows\system32\msvcrt.dll
ModLoad: 000007fe`fd0e0000 000007fe`fd1bb000   C:\Windows\system32\ADVAPI32.dll
ModLoad: 000007fe`fee60000 000007fe`fee7f000   C:\Windows\SYSTEM32\sechost.dll
ModLoad: 000007fe`fe920000 000007fe`fea4d000   C:\Windows\system32\RPCRT4.dll
ModLoad: 000007fe`fd2a0000 000007fe`fd2ce000   C:\Windows\system32\IMM32.DLL
ModLoad: 000007fe`fd370000 000007fe`fd479000   C:\Windows\system32\MSCTF.dll
ModLoad: 000007fe`fa440000 000007fe`fa443000   C:\Windows\system32\api-ms-win-core-synch-l1-2-0.DLL
ModLoad: 00000000`747b0000 00000000`7491e000   C:\Windows\system32\tmumh\20019\TmMon\2.8.0.1034\tmmon64.dll
ModLoad: 000007fe`faab0000 000007fe`faaeb000   C:\Windows\system32\winmm.dll
ModLoad: 000007fe`fef50000 000007fe`fef9d000   C:\Windows\system32\ws2_32.dll
ModLoad: 000007fe`ff070000 000007fe`ff078000   C:\Windows\system32\NSI.dll
ModLoad: 000007fe`fcb40000 000007fe`fcb4f000   C:\Windows\system32\cryptbase.dll
ModLoad: 000007fe`fb350000 000007fe`fb37c000   C:\Windows\system32\powrprof.dll
ModLoad: 000007fe`ff080000 000007fe`ff257000   C:\Windows\system32\SETUPAPI.dll
ModLoad: 000007fe`fcd80000 000007fe`fcdb6000   C:\Windows\system32\CFGMGR32.dll
ModLoad: 000007fe`fd1c0000 000007fe`fd29a000   C:\Windows\system32\OLEAUT32.dll
ModLoad: 000007fe`fec60000 000007fe`fee5c000   C:\Windows\system32\ole32.dll
ModLoad: 000007fe`fcdd0000 000007fe`fcdea000   C:\Windows\system32\DEVOBJ.dll
(2eb4.2e3c): Break instruction exception - code 80000003 (first chance)
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Windows\SYSTEM32\ntdll.dll - 
ntdll!DbgBreakPoint:
00000000`76ffafb0 cc              int     3
0:011> !uniqstack
Processing 12 threads, please wait
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Windows\system32\tmumh\20019\AddOn\8.50.0.2071\TmUmEvt64.dll - 
*** ERROR: Module load completed but symbols could not be loaded for C:\Windows\system32\tmumh\20019\TmMon\2.8.0.1034\tmmon64.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Windows\system32\KERNELBASE.dll - 
*** WARNING: Unable to verify timestamp for c:\Users\alexb\dev\go\pkg\tool\windows_amd64\compile.exe
*** ERROR: Module load completed but symbols could not be loaded for c:\Users\alexb\dev\go\pkg\tool\windows_amd64\compile.exe

.  0  Id: 2eb4.270c Suspend: 1 Teb: 000007ff`fffdd000 Unfrozen
      Start: compile+0x69500 (00000000`00469500) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`0022e618 00000000`76ff8f58 ntdll!ZwWaitForSingleObject+0xa
00000000`0022e620 00000000`76ff8e54 ntdll!RtlDeNormalizeProcessParams+0x5a8
00000000`0022e6d0 00000000`76ffe0b5 ntdll!RtlDeNormalizeProcessParams+0x4a4
00000000`0022e700 00000000`76ffddd8 ntdll!RtlAllocateHeap+0x455
00000000`0022e8e0 000007fe`fa553774 ntdll!RtlAllocateHeap+0x178
00000000`0022e9f0 000007fe`fa46427b TmUmEvt64!GetInterface+0x46e24
00000000`0022ea20 000007fe`fa4aef35 TmUmEvt64+0x1427b
00000000`0022ea50 000007fe`fa4cbea0 TmUmEvt64+0x5ef35
00000000`0022eaa0 000007fe`fa4cc560 TmUmEvt64+0x7bea0
00000000`0022eb70 000007fe`fa4d19f1 TmUmEvt64+0x7c560
00000000`0022ebc0 000007fe`fa4d4b8b TmUmEvt64+0x819f1
00000000`0022ec00 000007fe`fa4ceec8 TmUmEvt64+0x84b8b
00000000`0022f0f0 000007fe`fa4c0618 TmUmEvt64+0x7eec8
00000000`0022f120 000007fe`fa4e9730 TmUmEvt64+0x70618
00000000`0022f230 00000000`747df146 TmUmEvt64+0x99730
00000000`0022f470 00000000`74892d7d tmmon64+0x2f146
00000000`0022f550 00000000`748929f4 tmmon64+0xe2d7d
00000000`0022f610 00000000`747e30ac tmmon64+0xe29f4
00000000`0022f680 000007fe`fce17c3f tmmon64+0x330ac
00000000`0022f750 00000000`0046967e KERNELBASE!ResumeThread+0xf
00000000`0022f780 ffffffff`ffffffff compile+0x6967e
00000000`0022f788 00000000`00000000 0xffffffff`ffffffff
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Windows\system32\kernel32.dll - 

.  1  Id: 2eb4.2ed0 Suspend: 1 Teb: 000007ff`fffdb000 Unfrozen
      Start: tmmon64+0x8adac (00000000`7483adac) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`0395fcb8 000007fe`fce11430 ntdll!ZwWaitForMultipleObjects+0xa
00000000`0395fcc0 00000000`76da06c0 KERNELBASE!GetCurrentProcess+0x40
00000000`0395fdc0 00000000`7485eed4 kernel32!WaitForMultipleObjects+0xb0
00000000`0395fe50 00000000`7483ad07 tmmon64+0xaeed4
00000000`0395ff00 00000000`7483aeae tmmon64+0x8ad07
00000000`0395ff30 00000000`76da59cd tmmon64+0x8aeae
00000000`0395ff60 00000000`76fda561 kernel32!BaseThreadInitThunk+0xd
00000000`0395ff90 00000000`00000000 ntdll!RtlUserThreadStart+0x21

.  2  Id: 2eb4.1b48 Suspend: 1 Teb: 000007ff`fffd9000 Unfrozen
      Start: ntdll!RtlDestroyHandleTable+0x270 (00000000`76fcf6f0) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`03b5fcc8 00000000`76fced15 ntdll!ZwWaitForWorkViaWorkerFactory+0xa
00000000`03b5fcd0 00000000`76da59cd ntdll!RtlValidateHeap+0x155
00000000`03b5ff60 00000000`76fda561 kernel32!BaseThreadInitThunk+0xd
00000000`03b5ff90 00000000`00000000 ntdll!RtlUserThreadStart+0x21

.  3  Id: 2eb4.2b3c Suspend: 1 Teb: 000007ff`fffd7000 Unfrozen
      Start: ntdll!TpIsTimerSet+0x8b0 (00000000`76fca280) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`03d5fcb8 00000000`76fca3c7 ntdll!ZwWaitForMultipleObjects+0xa
00000000`03d5fcc0 00000000`76da59cd ntdll!TpIsTimerSet+0x9f7
00000000`03d5ff60 00000000`76fda561 kernel32!BaseThreadInitThunk+0xd
00000000`03d5ff90 00000000`00000000 ntdll!RtlUserThreadStart+0x21

.  4  Id: 2eb4.125c Suspend: 1 Teb: 000007ff`fffd5000 Unfrozen
      Start: compile+0x69940 (00000000`00469940) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2956e648 00000000`76ff8f58 ntdll!ZwWaitForSingleObject+0xa
00000000`2956e650 00000000`76ff8e54 ntdll!RtlDeNormalizeProcessParams+0x5a8
00000000`2956e700 00000000`76ffe0b5 ntdll!RtlDeNormalizeProcessParams+0x4a4
00000000`2956e730 00000000`76ffddd8 ntdll!RtlAllocateHeap+0x455
00000000`2956e910 000007fe`fa553774 ntdll!RtlAllocateHeap+0x178
00000000`2956ea20 000007fe`fa46427b TmUmEvt64!GetInterface+0x46e24
00000000`2956ea50 000007fe`fa4aef35 TmUmEvt64+0x1427b
00000000`2956ea80 000007fe`fa4cbea0 TmUmEvt64+0x5ef35
00000000`2956ead0 000007fe`fa4cc560 TmUmEvt64+0x7bea0
00000000`2956eba0 000007fe`fa4d19f1 TmUmEvt64+0x7c560
00000000`2956ebf0 000007fe`fa4d4b8b TmUmEvt64+0x819f1
00000000`2956ec30 000007fe`fa4ceec8 TmUmEvt64+0x84b8b
00000000`2956f120 000007fe`fa4c0618 TmUmEvt64+0x7eec8
00000000`2956f150 000007fe`fa4e9730 TmUmEvt64+0x70618
00000000`2956f260 00000000`747df146 TmUmEvt64+0x99730
00000000`2956f4a0 00000000`74892d7d tmmon64+0x2f146
00000000`2956f580 00000000`748929f4 tmmon64+0xe2d7d
00000000`2956f640 00000000`747e30ac tmmon64+0xe29f4
00000000`2956f6b0 000007fe`fce17c3f tmmon64+0x330ac
00000000`2956f780 00000000`0046967e KERNELBASE!ResumeThread+0xf
00000000`2956f7b0 ffffffff`ffffffff compile+0x6967e
00000000`2956f7b8 00000000`00000001 0xffffffff`ffffffff
00000000`2956f7c0 ffffffff`ffffffff 0x1
00000000`2956f7c8 00000000`2956f928 0xffffffff`ffffffff
00000000`2956f7d0 00000000`00000000 0x2956f928

.  5  Id: 2eb4.2a8c Suspend: 1 Teb: 000007ff`fffd3000 Unfrozen
      Start: compile+0x69940 (00000000`00469940) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2976fbc8 000007fe`fce110ac ntdll!ZwWaitForSingleObject+0xa
00000000`2976fbd0 00000000`0046967e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`2976fc70 000000c0`0002ca78 compile+0x6967e
00000000`2976fc78 00000000`02030000 0xc0`0002ca78
00000000`2976fc80 00000000`00000000 0x2030000

.  6  Id: 2eb4.2670 Suspend: 3 Teb: 000007ff`fffae000 Unfrozen
      Start: compile+0x69940 (00000000`00469940) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2996e638 00000000`7701cf71 ntdll!RtlUnlockHeap+0x90
00000000`2996e640 00000000`76ffddd8 ntdll!TpAlpcRegisterCompletionList+0xaf91
00000000`2996e820 000007fe`fa553774 ntdll!RtlAllocateHeap+0x178
00000000`2996e930 000007fe`fa46427b TmUmEvt64!GetInterface+0x46e24
00000000`2996e960 000007fe`fa4aef35 TmUmEvt64+0x1427b
00000000`2996e990 000007fe`fa4cbea0 TmUmEvt64+0x5ef35
00000000`2996e9e0 000007fe`fa4cc560 TmUmEvt64+0x7bea0
00000000`2996eab0 000007fe`fa4d19f1 TmUmEvt64+0x7c560
00000000`2996eb00 000007fe`fa4d4b8b TmUmEvt64+0x819f1
00000000`2996eb40 000007fe`fa4ceec8 TmUmEvt64+0x84b8b
00000000`2996f030 000007fe`fa4c0618 TmUmEvt64+0x7eec8
00000000`2996f060 000007fe`fa4e9730 TmUmEvt64+0x70618
00000000`2996f170 00000000`747df146 TmUmEvt64+0x99730
00000000`2996f3b0 00000000`74892d7d tmmon64+0x2f146
00000000`2996f490 00000000`748929f4 tmmon64+0xe2d7d
00000000`2996f550 00000000`747e30ac tmmon64+0xe29f4
00000000`2996f5c0 000007fe`fce17c3f tmmon64+0x330ac
00000000`2996f690 00000000`0046967e KERNELBASE!ResumeThread+0xf
00000000`2996f6c0 ffffffff`ffffffff compile+0x6967e
00000000`2996f6c8 00000000`00000001 0xffffffff`ffffffff
00000000`2996f6d0 ffffffff`ffffffff 0x1
00000000`2996f6d8 00000000`2996f840 0xffffffff`ffffffff
00000000`2996f6e0 00000000`00000000 0x2996f840

.  7  Id: 2eb4.2870 Suspend: 1 Teb: 000007ff`fffac000 Unfrozen
      Start: compile+0x69940 (00000000`00469940) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`29e7fb08 000007fe`fce110ac ntdll!ZwWaitForSingleObject+0xa
00000000`29e7fb10 00000000`0046967e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`29e7fbb0 000000c0`00400278 compile+0x6967e
00000000`29e7fbb8 00000000`0041f9d7 0xc0`00400278
00000000`29e7fbc0 000000c0`00000000 compile+0x1f9d7
00000000`29e7fbc8 00000000`00000188 0xc0`00000000
00000000`29e7fbd0 00000000`00000000 0x188

.  8  Id: 2eb4.2f24 Suspend: 2 Teb: 000007ff`fffaa000 Unfrozen
      Start: compile+0x69940 (00000000`00469940) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2a07fba8 000007fe`fce11945 ntdll!ZwAllocateVirtualMemory+0xa
00000000`2a07fbb0 00000000`747e0631 KERNELBASE!VirtualAlloc+0x45
00000000`2a07fbf0 00000000`0046967e tmmon64+0x30631
00000000`2a07fcc0 000000c0`013aa000 compile+0x6967e
00000000`2a07fcc8 00000000`00002000 0xc0`013aa000
00000000`2a07fcd0 00000000`00001000 0x2000
00000000`2a07fcd8 00000000`00000004 0x1000
00000000`2a07fce0 00000000`00000012 0x4
00000000`2a07fce8 00000000`00000003 0x12
00000000`2a07fcf0 00000000`00000000 0x3

.  9  Id: 2eb4.2188 Suspend: 1 Teb: 000007ff`fffa8000 Unfrozen
      Start: compile+0x69940 (00000000`00469940) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2a28fbd8 000007fe`fce110ac ntdll!ZwWaitForSingleObject+0xa
00000000`2a28fbe0 00000000`0046967e KERNELBASE!WaitForSingleObjectEx+0x9c
00000000`2a28fc80 000000c0`00388278 compile+0x6967e
00000000`2a28fc88 00000000`00000000 0xc0`00388278

. 10  Id: 2eb4.25c8 Suspend: 1 Teb: 000007ff`fffa6000 Unfrozen
      Start: ntdll!RtlDestroyHandleTable+0x270 (00000000`76fcf6f0) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2a56f418 00000000`76ff8f58 ntdll!ZwWaitForSingleObject+0xa
00000000`2a56f420 00000000`76ff8e54 ntdll!RtlDeNormalizeProcessParams+0x5a8
00000000`2a56f4d0 00000000`76ffe0b5 ntdll!RtlDeNormalizeProcessParams+0x4a4
00000000`2a56f500 00000000`76ffddd8 ntdll!RtlAllocateHeap+0x455
00000000`2a56f6e0 000007fe`fa5537eb ntdll!RtlAllocateHeap+0x178
00000000`2a56f7f0 000007fe`fa52a163 TmUmEvt64!GetInterface+0x46e9b
00000000`2a56f820 000007fe`fa529c2d TmUmEvt64!GetInterface+0x1d813
00000000`2a56f850 000007fe`fa525c19 TmUmEvt64!GetInterface+0x1d2dd
00000000`2a56f880 000007fe`fa525fc9 TmUmEvt64!GetInterface+0x192c9
00000000`2a56f8b0 000007fe`fa5261f9 TmUmEvt64!GetInterface+0x19679
00000000`2a56f8e0 00000000`76fda719 TmUmEvt64!GetInterface+0x198a9
00000000`2a56f940 00000000`76fda46f ntdll!RtlUserThreadStart+0x1d9
00000000`2a56fa40 00000000`76fda36e ntdll!LdrInitializeThunk+0x10f
00000000`2a56fab0 00000000`00000000 ntdll!LdrInitializeThunk+0xe

. 11  Id: 2eb4.2e3c Suspend: 1 Teb: 000007ff`fffa4000 Unfrozen
      Start: ntdll!DbgUiRemoteBreakin (00000000`770a2dd0) 
      Priority: 0  Priority class: 32  Affinity: f
Child-SP          RetAddr           Call Site
00000000`2a76ff28 00000000`770a2e08 ntdll!DbgBreakPoint
00000000`2a76ff30 00000000`76da59cd ntdll!DbgUiRemoteBreakin+0x38
00000000`2a76ff60 00000000`76fda561 kernel32!BaseThreadInitThunk+0xd
00000000`2a76ff90 00000000`00000000 ntdll!RtlUserThreadStart+0x21

Total threads: 12

Alex

k3bvogb1

k3bvogb15#

感谢您提供的两个dump。
我在周围进行了更多的搜索,我几乎可以确定tmmon64和TmUmEvt64与趋势科技杀毒软件有关,这与您在#36492(评论)中所说的相符。
不幸的是,我认为它的系统调用拦截正在引入一个导致死锁的锁周期。
在#36492(评论)中,线程6和8的挂起计数大于1。线程0和6(再次)处于ResumeThread中。因此,线程6必须因抢占而暂停线程8,然后当它试图恢复线程8时,线程0因抢占而暂停线程6。有趣的是,这三个线程都通过tmmon64/TmUmEvt64进入Windows内存分配函数。我的猜测是在线程0和6之间有一个循环:线程6上的TmUmEvt64锁定了ResumeThread中的Windows堆,然后带着这个锁被挂起。当线程0试图用ResumeThread恢复它时,TmUmEvt64再次尝试锁定Windows堆,但无法获得该锁,所以陷入僵局。

36492(评论)显示了类似的证据:线程6在RtlUnlockHeap(通过TmUmEvt64)中被挂起,线程4在GetThreadContext -> TmUmEvt64 -> RtlAllocateHeap中,表明它已经挂起线程6并且在Windows堆锁上陷入了一个锁周期。即使通过移动解锁完全串行化线程挂起/恢复也无法提供足够的帮助,因为TmUmEvt64可以通过其他方式进入Windows堆函数。

因此,最终,这可能是趋势科技的一个bug,但这只是因为我们在挂起自己的线程方面做了一些非常不寻常的事情,这很遗憾,很可能是我们的问题。使用SuspendThread的缺点越来越多,但我不知道有什么可以替代它。 :(

agyaoht7

agyaoht76#

迷人。似乎.NET使用SuspendThread来驱动线程到GC安全点。他们似乎在Windows堆锁方面遇到了类似的问题,尽管与系统调用拦截器没有具体关系。

我没有在threadsuspend.cpp中看到任何显然与我们不同的东西,但有一个关于操作系统资源和SuspendThread的巨大注解,表明它们仔细同步每次进入和离开托管代码的过渡(假设这包括每个“系统调用”),因此它们甚至不尝试挂起不在托管代码中的线程。如果我正确地跟踪了这些曲折的通道,最终会到达DisablePreemptiveGC、EnablePreemptiveGC和RareDisablePreemptiveGC、RareEnablePreemptiveGC,它们看起来可以根据GC抢占状态阻止进入和离开托管代码的过渡。

q5lcpyga

q5lcpyga7#

我又在周围做了一些搜索,我几乎确定tmmon64和TmUmEvt64与趋势科技杀毒软件有关。
你可能是对的。我在工作中使用这台电脑。我们的管理员在上面运行他们喜欢的任何软件。
我们正在做一些非常不寻常的事情,暂停我们自己的线程,这很遗憾,可能使这个问题成为我们的。
我同意。我在那台电脑上运行了很多不同的程序,没有一个程序会挂起。
这使得Go构建工具无法在这台电脑上使用。我怀疑用Go构建的程序也是如此。
这台电脑仍然运行着Windows 7 - 这在这些天里很少见。希望这个bug是罕见的。
使用SuspendThread的缺点越来越多,但我不知道有什么可以替代它。:(
就我个人而言,我不认为抢占有任何好处。我在Windows上不运行任何需要抢占的代码。我会只是在Windows上禁用抢占代码。你也将避免在Windows上遇到Delve问题。
有趣。看起来.NET使用SuspendThread来驱动线程到GC安全点。似乎他们在Windows堆锁方面遇到了类似的问题,尽管不是特别与系统调用拦截器相关。
这是完全可能的。但我预计会看到像Windows API描述中提到的那样的限制。我没有意识到有任何这样的东西。
添加@zx2c4,以防他有一些聪明的想法。
Alex

qlfbtfca

qlfbtfca8#

另一个尝试验证此问题的方法。我检查了ec51703(标记为go1.17)。这次更难打破它 - 它花了我3次运行make.bat才挂起。我不确定这是因为Go的新版本,还是因为我的操作系统上的软件发生了变化,或者是因为我的电脑超载或负载不足与其他程序。
以下是我的环境配置:

set HOME=c:\users\alexb\dev\
set GOROOT=%HOME%\go
set GOROOT_BOOTSTRAP=%HOME%\go1.4
set GOPATH=%HOME%
set MINGW=%HOME%\tdm_gcc_64_5.1.0
set PATH=%PATH%;%MINGW%\bin;%GOROOT%\bin
cd %GOROOT%\src
cmd

以下是我所做的:

c:\Users\alexb\dev\go\src>git rev-parse HEAD
ec5170397c724a8ae440b2bc529f857c86f0e6b1

c:\Users\alexb\dev\go\src>make
Building Go cmd/dist using c:\users\alexb\dev\\go1.4
Building Go toolchain1 using c:\users\alexb\dev\\go1.4.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for windows/amd64.
---
Installed Go for windows/amd64 in c:\Users\alexb\dev\go
Installed commands in c:\Users\alexb\dev\go\bin

c:\Users\alexb\dev\go\src>make
Building Go cmd/dist using c:\users\alexb\dev\\go1.4
Building Go toolchain1 using c:\users\alexb\dev\\go1.4.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for windows/amd64.
---
Installed Go for windows/amd64 in c:\Users\alexb\dev\go
Installed commands in c:\Users\alexb\dev\go\bin

c:\Users\alexb\dev\go\src>make
Building Go cmd/dist using c:\users\alexb\dev\\go1.4
Building Go toolchain1 using c:\users\alexb\dev\\go1.4.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for windows/amd64.

以下是在Process Explorer程序中挂起的Go构建过程树的截图:

设置set GODEBUG=asyncpreemptoff=1主要解决了我在构建和使用Go时遇到的问题。
不幸的是,如果我在运行时包中运行一些测试,Go仍然会挂起,因为一些测试会静默地清除GODEBUG环境变量。只需搜索runtime包以获取有关internal/testenv.CleanCmdEnv使用的详细信息。
Alex

相关问题