【发布时间】:2018-07-12 12:15:06
【问题描述】:
首先,我是不同 .NET 平台的新手。
我正在尝试使用 Windbg 调查托管 .Net 应用程序的转储(我不知道版本)。
为了做到这一点,我想启动!DumpHeap -stat 命令。
起初,这不起作用,因为 sos 未加载:
0:000> !DumpHeap -stat
No export DumpHeap found
0:000> .load sos
不过,似乎还有一个问题:
0:000> !DumpHeap -stat
The garbage collector data structures are not in a valid state for traversal.
It is either in the "plan phase," where objects are being moved around, or
we are at the initialization or shutdown of the gc heap. Commands related to
displaying, finding or traversing objects as well as gc heap segments may not
work properly. !dumpheap and !verifyheap may incorrectly complain of heap
consistency errors.
Object <exec cmd="!ListNearObj /d b331dbb0">b331dbb0</exec> has an invalid method table.
在网上,我找到了一些帖子,提到这个问题可能是版本不匹配造成的,这看起来可以通过.chain结果确认:
0:000> .chain
Extension DLL search Path:
=> Hereby my entire %PATH% environment variable
Extension DLL chain:
C:\ProgramData\dbg\sym\SOS_x86_x86_4.7.2563.00.dll\5A334E146eb000\SOS_x86_x86_4.7.2563.00.dll: image 4.7.2563.0, API 1.0.0, built Fri Dec 15 05:16:06 2017
[path: C:\ProgramData\dbg\sym\SOS_x86_x86_4.7.2563.00.dll\5A334E146eb000\SOS_x86_x86_4.7.2563.00.dll]
sos: image 4.6.1087.0, API 1.0.0, built Wed Nov 30 05:49:55 2016
[path: C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\sos.dll]
如您所见,确实似乎存在版本不匹配:
C:\...\SOS (ALL CAPS) seems to be of version 4.7.2653
sos (small letters) seems to be of version 4.6.1087
让我们解决这个问题:
0:000> .unload C:\ProgramData\dbg\sym\SOS_x86_x86_4.7.2563.00.dll\5A334E146eb000\SOS_x86_x86_4.7.2563.00.dll
0:000> .load C:\ProgramData\dbg\sym\SOS_x86_x86_4.6.1087.00.dll\583E5B8E6b1000\SOS_x86_x86_4.6.1087.00.dll
// I found this file, somewhere on my PC, I just hope it's correct :-)
这能解决问题吗?好像没有:
0:000> !DumpHeap -stat
The garbage collector data structures are not in a valid state for traversal.
It is either in the "plan phase," where objects are being moved around, or
we are at the initialization or shutdown of the gc heap. Commands related to
displaying, finding or traversing objects as well as gc heap segments may not
work properly. !dumpheap and !verifyheap may incorrectly complain of heap
consistency errors.
Object <exec cmd="!ListNearObj /d b331dbb0">b331dbb0</exec> has an invalid method table.
好的。所以还是没有解决办法。莫非还有其他版本不对?
0:000> .cordll
CLR DLL status: Loaded DLL C:\ProgramData\dbg\sym\mscordacwks_x86_x86_4.7.2563.00.dll\5A334E146eb000\mscordacwks_x86_x86_4.7.2563.00.dll
确实,CLR 似乎也指的是那个错误的版本。让我们解决这个问题:
0:000> .cordll -u
CLR DLL status: No load attempts
(先卸载当前的,再加载新的)
0:000> .cordll -lp C:\ProgramData\dbg\sym\mscordacwks_x86_x86_4.6.1087.00.dll\583E5B8E6b1000\mscordacwks_x86_x86_4.6.1087.00.dll
// Again a file I found somewhere on my PC, but it seems not to be working:
CLRDLL: Consider using ".cordll -lp <path>" command to specify .NET runtime directory.
CLR DLL status: ERROR: Unable to load DLL C:\ProgramData\dbg\sym\mscordacwks_x86_x86_4.6.1087.00.dll\583E5B8E6b1000\mscordacwks_x86_x86_4.6.1087.00.dll\mscordacwks_x86_x86_4.7.2563.00.dll, Win32 error 0n87
现在我别无选择:在谷歌搜索 Win32 error 0n87 时,我发现有关错误参数的信息,转储调查出错,但不是加载此 CLR DLL 的方法。
有人可以在这里帮助我吗(也许我们可以先确定我需要选择哪个版本,我只是随机选择了:-))?
提前致谢
【问题讨论】:
-
.NET 进程的小型转储不能是小型的。它需要包括整个 GC 堆。与客户交谈,询问他们是如何创建它的。请记住,你得到这个小型转储是因为程序行为不端。有内存损坏问题的程序确实倾向于在 GC 发生的那一刻急剧下降。你必须知道你需要寻找什么来避免大海捞针的问题。这是一大堆。
-
@HansPassant:如果没有完整的堆信息,SOS 会在加载扩展时输出警告。