记一个托管的dump无法查看托管调用栈的问题

朋友让我帮忙看一个dump, 我打开看了看, 发现一个怪异的问题.

用命令"~*e!clrstack"查看所有线程的托管调用栈, 居然说所有的线程都不是托管线程.

0:045> ~*e!clrstack
OS Thread Id: 0x16d4 (0)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process
OS Thread Id: 0x260c (1)
Unable to walk the managed stack. The current thread is likely not a
managed thread. You can run !threads to get a list of managed threads in
the process

用"~*e k" 明明看到有如下这样的调用栈:

Child-SP          RetAddr           Call Site
00000000`02baf698 000007fe`fd2010ac ntdll!NtWaitForSingleObject+0xa
00000000`02baf6a0 000007fe`f4cc9b96 KERNELBASE!WaitForSingleObjectEx+0x79
00000000`02baf740 000007fe`f4cc9a9f mscorwks!CLREventWaitHelper+0x42 [f:\dd\ndp\clr\src\vm\synch.cpp @ 699]
00000000`02baf7a0 000007fe`f4cc97fb mscorwks!CLREvent::WaitEx+0x63 [f:\dd\ndp\clr\src\vm\synch.cpp @ 798]
00000000`02baf850 000007fe`f4cba44a mscorwks!ThreadpoolMgr::SafeWait+0x7b [f:\dd\ndp\clr\src\vm\win32threadpool.cpp @ 3042]
00000000`02baf910 000007fe`f4d1095c mscorwks!ThreadpoolMgr::WorkerThreadStart+0x11a [f:\dd\ndp\clr\src\vm\win32threadpool.cpp @ 2721]
00000000`02baf9b0 00000000`76f8f56d mscorwks!Thread::intermediateThreadProc+0x78 [f:\dd\ndp\clr\src\vm\threads.cpp @ 3060]
00000000`02bafb80 00000000`771c3281 kernel32!BaseThreadInitThunk+0xd
00000000`02bafbb0 00000000`00000000 ntdll!RtlUserThreadStart+0x1d

 

注意看其中的mscorwks, 明明是托管的模块呀.

问了一下同事, 得到了的答复是: "这是一个已知问题." 可以使用命令"lmvm clr", 看输出结果中是不是带有.net framework 4.0的信息.

0:045> lmvm clr
start             end                 module name
000007fe`f96a0000 000007fe`fa005000   clr        (pdb symbols)          d:\symcache\clr.pdb\0A821B8A573E42899202851DF6A539F12\clr.pdb
    Loaded symbol image file: clr.dll
    Image path: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
    Image name: clr.dll
    Timestamp:        Thu Mar 18 20:39:07 2010 (4BA21EEB)
    CheckSum:         00959DBD
    ImageSize:        00965000
    File version:     4.0.30319.1
    Product version:  4.0.30319.1
    File flags:       8 (Mask 3F) Private
    File OS:          4 Unknown Win32
    File type:        2.0 Dll
    File date:        00000000.00000000
    Translations:     0409.04b0
    CompanyName:      Microsoft Corporation
    ProductName:      Microsoft® .NET Framework
    InternalName:     clr.dll
    OriginalFilename: clr.dll
    ProductVersion:   4.0.30319.1
    FileVersion:      4.0.30319.1 (RTMRel.030319-0100)
    PrivateBuild:     DDBLD431
    FileDescription:  Microsoft .NET Runtime Common Language Runtime - WorkStation
    LegalCopyright:   © Microsoft Corporation.  All rights reserved.
    Comments:         Flavor=Retail

如上所示, 这个dump中带有.net framework 4.0。 而这个dump中需要查看的是.net 2.0的application的问题, 所以, 在这个dump中, 包含了2.0和4.0两个版本的framework. 所以WinDBG就confuse了, 不知道该加载哪一个版本的mscordacwks的dll.

解决方法

===============

运行命令".cordll -ve -u -I mscorwks -l"

0:045> .cordll -ve -u -I mscorwks -l
CLRDLL: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscordacwks.dll:2.0.50727.4952 f:0
doesn't match desired version 2.0.50727.4927 f:0
DBGHELP: d:\symcache\mscordacwks_AMD64_AMD64_2.0.50727.4927.dll\4A27466F9ae000\mscordacwks_AMD64_AMD64_2.0.50727.4927.dll - OK
CLRDLL: Loaded DLL d:\symcache\mscordacwks_AMD64_AMD64_2.0.50727.4927.dll\4A27466F9ae000\mscordacwks_AMD64_AMD64_2.0.50727.4927.dll
CLR DLL status: Loaded DLL d:\symcache\mscordacwks_AMD64_AMD64_2.0.50727.4927.dll\4A27466F9ae000\mscordacwks_AMD64_AMD64_2.0.50727.4927.dll

 

再看该dump中的托管调用栈, 问题解决.

原文地址:https://www.cnblogs.com/awpatp/p/1908385.html