使用 WinDBG 进行事后调试

发布于 2024-10-09 20:43:38 字数 4444 浏览 0 评论 0原文

我有一个 WCF 服务在服务器上运行,偶尔(每月 1-2 次)它会抛出 COMException 并显示信息性消息“未知错误 (0x8005008)”。当我用 google 搜索这个特定错误时,我只得到了有关在 IIS 中创建虚拟目录时出现的问题的线索。而且源代码中没有任何关于在 IIS 中创建虚拟目录的内容。

DirectoryServiceLib.LdapProvider.Directory - CreatePost - Could not create employee for 195001010000,000000000000: System.Runtime.InteropServices.COMException (0x80005008): Unknown error (0x80005008) at System.DirectoryServices.PropertyValueCollection.PopulateList

当我捕获异常时,我会进行内存转储,以便在 WinDBG 中进行进一步分析。切换到正确的线程后,我执行了!CLRStack命令:

000000001b8ab6d8 000000007708671a [NDirectMethodFrameStandalone: 000000001b8ab6d8] Common.MemoryDump.MiniDumpWriteDump(IntPtr, Int32, IntPtr, MINIDUMP_TYPE, IntPtr, IntPtr, IntPtr)
000000001b8ab680 000007ff002808d8 DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, Int32, IntPtr, MINIDUMP_TYPE, IntPtr, IntPtr, IntPtr)
000000001b8ab780 000007ff00280812 Common.MemoryDump.CreateMiniDump(System.String)
000000001b8ab7e0 000007ff0027b218 DirectoryServiceLib.LdapProvider.Directory.CreatePost(System.String, DirectoryServiceLib.Model.Post, DirectoryServiceLib.Model.Presumptions, Services.Common.SourceEnum, System.String)
000000001b8ad6d8 000007fef8816869 [HelperMethodFrame: 000000001b8ad6d8] 
000000001b8ad820 000007feec2b6c6f System.DirectoryServices.PropertyValueCollection.PopulateList()
000000001b8ad860 000007feec225f0f System.DirectoryServices.PropertyValueCollection..ctor(System.DirectoryServices.DirectoryEntry, System.String)
000000001b8ad8a0 000007feec22d023 System.DirectoryServices.PropertyCollection.get_Item(System.String)
000000001b8ad8f0 000007ff00274d34 Common.DirectoryEntryExtension.GetStringAttribute(System.String)
000000001b8ad940 000007ff0027f507 DirectoryServiceLib.LdapProvider.DirectoryPost.Copy(DirectoryServiceLib.LdapProvider.DirectoryPost)
000000001b8ad980 000007ff0027a7cf DirectoryServiceLib.LdapProvider.Directory.CreatePost(System.String, DirectoryServiceLib.Model.Post, DirectoryServiceLib.Model.Presumptions, Services.Common.SourceEnum, System.String)
000000001b8adbe0 000007ff00279532 DirectoryServiceLib.WCFDirectory.CreatePost(System.String, DirectoryServiceLib.Model.Post, DirectoryServiceLib.Model.Presumptions, Services.Common.SourceEnum, System.String)
000000001b8adc60 000007ff001f47bd DynamicClass.SyncInvokeCreatePost(System.Object, System.Object[], System.Object[])

我的结论是,当代码调用时它失败了 System.DirectoryServices.PropertyCollection.get_Item(System.String).

因此,在发出 !CLRStack -a 之后,我得到以下结果:

000000001b8ad8a0 000007feec22d023 System.DirectoryServices.PropertyCollection.get_Item(System.String)
   PARAMETERS:
      this = <no data>
      propertyName = <no data>
   LOCALS:
      <CLR reg> = 0x0000000001dcef78
      <no data>

我的第一个问题是为什么它在属性名称上不显示任何数据?我对 Windbg 还算陌生。但是,我在 = 0x0000000001dcef78 上执行了转储对象:

0:013> !do 0x0000000001dcef78
Name:        System.String
MethodTable: 000007fef66d6960
EEClass:     000007fef625eec8
Size:        74(0x4a) bytes
File:        C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
String:      personalprescriptioncode
Fields:
                  MT    Field   Offset                 Type VT     Attr            Value Name
000007fef66dc848  40000ed        8         System.Int32  1 instance               24 m_stringLength
000007fef66db388  40000ee        c          System.Char  1 instance               70 m_firstChar
000007fef66d6960  40000ef       10        System.String  0   shared           static Empty
                                 >> Domain:Value  0000000000174e10:00000000019d1420 000000001a886f50:00000000019d1420 <<

因此,当源代码想要从 Active Directory(用于持久层的内容)获取个人处方代码时,它会失败。回顾一下堆栈,这是发出 Copy 方法时的情况。 DirectoryServiceLib.LdapProvider.DirectoryPost.Copy(DirectoryServiceLib.LdapProvider.DirectoryPost)

因此,查看源代码:

DirectoryPost postInLimbo = DirectoryPostFactory.Instance().GetDirectoryPost(LdapConfigReader.Instance().GetConfigValue("LimboDN"), idGenPerson.ID.UserId);
if (postInLimbo != null)
   newPost.Copy(postInLimbo);

此代码正在 OU=limbo 中查找具有相同 UserId 的另一篇文章,如果找到,则复制新帖子的属性。在这种情况下,它确实如此,但由于个人处方代码而失败。我在 OU=Limbo 下的 Active Directory 中进行了查找,该帖子的属性为 individualprescriptioncode=31243。

问题1:为什么有些PARAMETERS和LOCALS没有显示数据?是否是GC在内存转储创建之前就进行了清理?

问题2:我还能做些什么来解决这个问题吗?

I have an WCF-service running on an server, and occasionally(1-2 times every month) it throws an COMException with the informative message ”Unknown error (0x8005008)”. When i googled for this particular error I only got threads about problems when creating virtual directories in IIS. And the source code hasn’t anything with making a virtual directory in IIS.

DirectoryServiceLib.LdapProvider.Directory - CreatePost - Could not create employee for 195001010000,000000000000: System.Runtime.InteropServices.COMException (0x80005008): Unknown error (0x80005008) at System.DirectoryServices.PropertyValueCollection.PopulateList

I've taken a memorydump when I catch the Exception for further analysis in WinDBG. After switching to the right thread I executed the !CLRStack command:

000000001b8ab6d8 000000007708671a [NDirectMethodFrameStandalone: 000000001b8ab6d8] Common.MemoryDump.MiniDumpWriteDump(IntPtr, Int32, IntPtr, MINIDUMP_TYPE, IntPtr, IntPtr, IntPtr)
000000001b8ab680 000007ff002808d8 DomainBoundILStubClass.IL_STUB_PInvoke(IntPtr, Int32, IntPtr, MINIDUMP_TYPE, IntPtr, IntPtr, IntPtr)
000000001b8ab780 000007ff00280812 Common.MemoryDump.CreateMiniDump(System.String)
000000001b8ab7e0 000007ff0027b218 DirectoryServiceLib.LdapProvider.Directory.CreatePost(System.String, DirectoryServiceLib.Model.Post, DirectoryServiceLib.Model.Presumptions, Services.Common.SourceEnum, System.String)
000000001b8ad6d8 000007fef8816869 [HelperMethodFrame: 000000001b8ad6d8] 
000000001b8ad820 000007feec2b6c6f System.DirectoryServices.PropertyValueCollection.PopulateList()
000000001b8ad860 000007feec225f0f System.DirectoryServices.PropertyValueCollection..ctor(System.DirectoryServices.DirectoryEntry, System.String)
000000001b8ad8a0 000007feec22d023 System.DirectoryServices.PropertyCollection.get_Item(System.String)
000000001b8ad8f0 000007ff00274d34 Common.DirectoryEntryExtension.GetStringAttribute(System.String)
000000001b8ad940 000007ff0027f507 DirectoryServiceLib.LdapProvider.DirectoryPost.Copy(DirectoryServiceLib.LdapProvider.DirectoryPost)
000000001b8ad980 000007ff0027a7cf DirectoryServiceLib.LdapProvider.Directory.CreatePost(System.String, DirectoryServiceLib.Model.Post, DirectoryServiceLib.Model.Presumptions, Services.Common.SourceEnum, System.String)
000000001b8adbe0 000007ff00279532 DirectoryServiceLib.WCFDirectory.CreatePost(System.String, DirectoryServiceLib.Model.Post, DirectoryServiceLib.Model.Presumptions, Services.Common.SourceEnum, System.String)
000000001b8adc60 000007ff001f47bd DynamicClass.SyncInvokeCreatePost(System.Object, System.Object[], System.Object[])

My conclusion is that it fails when the code is calling
System.DirectoryServices.PropertyCollection.get_Item(System.String).

So after issuing an !CLRStack -a I get this result:

000000001b8ad8a0 000007feec22d023 System.DirectoryServices.PropertyCollection.get_Item(System.String)
   PARAMETERS:
      this = <no data>
      propertyName = <no data>
   LOCALS:
      <CLR reg> = 0x0000000001dcef78
      <no data>

My very first question is why does it display no data on the propertyname? I am kinda new on Windbg. However I executed an dumpobject on = 0x0000000001dcef78:

0:013> !do 0x0000000001dcef78
Name:        System.String
MethodTable: 000007fef66d6960
EEClass:     000007fef625eec8
Size:        74(0x4a) bytes
File:        C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
String:      personalprescriptioncode
Fields:
                  MT    Field   Offset                 Type VT     Attr            Value Name
000007fef66dc848  40000ed        8         System.Int32  1 instance               24 m_stringLength
000007fef66db388  40000ee        c          System.Char  1 instance               70 m_firstChar
000007fef66d6960  40000ef       10        System.String  0   shared           static Empty
                                 >> Domain:Value  0000000000174e10:00000000019d1420 000000001a886f50:00000000019d1420 <<

So when the source code wants to fetch the personalprescriptioncode from Active Directory(what is used for persistence layer) it fails. Looking back at the stack it is when issuing the Copy method.
DirectoryServiceLib.LdapProvider.DirectoryPost.Copy(DirectoryServiceLib.LdapProvider.DirectoryPost)

So looking in the sourcecode:

DirectoryPost postInLimbo = DirectoryPostFactory.Instance().GetDirectoryPost(LdapConfigReader.Instance().GetConfigValue("LimboDN"), idGenPerson.ID.UserId);
if (postInLimbo != null)
   newPost.Copy(postInLimbo);

This code is looking for another post in OU=limbo with the same UserId and if it finds one it copies the attributes to the new post. In this case it does and it fails with personalprescriptioncode. I've looked in Active Directory under OU=Limbo and the post exist there with the attribute personalprescriptioncode=31243.

Question 1: Why does it display no data for some of the PARAMETERS and LOCALS? Is it the GC who has cleaned up before the memorydump had been created.

Question 2: Is there anymore i can do to get to the solution to this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南笙 2024-10-16 20:43:38
//
// MessageId: E_ADS_BAD_PARAMETER
//
// MessageText:
//
//  One or more input parameters are invalid
//
#define E_ADS_BAD_PARAMETER              _HRESULT_TYPEDEF_(0x80005008L)

您看不到参数/局部变量值,因为代码已经过优化。它们在调用时存储在 CPU 寄存器中,而不是堆栈帧中。你再也无法大海捞针了。

//
// MessageId: E_ADS_BAD_PARAMETER
//
// MessageText:
//
//  One or more input parameters are invalid
//
#define E_ADS_BAD_PARAMETER              _HRESULT_TYPEDEF_(0x80005008L)

You can't see the argument/local variable values because the code is optimized. They are stored in CPU registers at the time of the call, not the stack frame. You can't find the needle in the haystack anymore.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文