死锁还是在循环中等待?

时间:2015-08-04 13:22:06

标签: c# c c++-cli deadlock windbg

民间,

我正在尝试跟踪我的应用程序停止响应事件的原因。

一些背景: 有问题的应用程序My_C_Application是一个(带有C和C ++代码的C应用程序)它还引用了一个.Net dll,它将功能公开为COM对象, 这些是使用regasm注册的,相关的tlh用于解析这些类的加载和使用。该应用程序还使用第三方消息库 IPWorks,我们在这里使用SSL版本的c ++,这与其他基于IP的.net系统进行了对话。这些其他系统使用.Net版本的IpWorks, My_C_Application充当业务逻辑引擎,其他应用程序处理数据,GUI等。

这一切似乎在测试中都很好用。在许多客户端站点中,在一些客户端站点中,我们收到GUI没有响应点击的报告(现在我们已经看到了这一点) 在网站上发生,GUI正在关键按键并且批准地发送它的消息)似乎My_C_Application没有处理/接收事件。

我们发现了这个问题并使用procdump -mp我们得到了一个转储来分析。

我使用我们自己的应用程序为Crashes自动执行此操作,该应用程序调用windbg的控制台版本,我们执行以下命令以进行崩溃:

!analyze -v; .ecxr;

现在我明白这对挂起没用,所以我在为我设置了符号路径之后再执行其他命令等。

    Opened log file 'C:\crash\AutomateCrashAnalysis\AutomateCrashAnalysis\bin\Debug\CrashSummary1584124051.txt'

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


    Loading Dump File [C:\Crash\My_C_Application.exe_150804_094908.dmp\My_C_Application.exe_150804_094908.dmp]
    User Mini Dump File: Only registers, stack and portions of memory are available

    Comment: '
    *** procdump.exe -mp 7908
    *** Manual dump'
    Symbol search path is: C:\crash\AutomateCrashAnalysis\AutomateCrashAnalysis\bin\Debug\My_C_Application___Win32_Debug;srv*C:\SYMBOLS*http://msdl.microsoft.com/download/symbols
    Executable search path is: C:\crash\AutomateCrashAnalysis\AutomateCrashAnalysis\bin\Debug\My_C_Application___Win32_Debug
    Windows XP Version 2600 (Service Pack 3) UP Free x86 compatible
    Product: WinNt, suite: SingleUserTS
    Machine Name:
    Debug session time: Tue Aug  4 09:49:13.000 2015 (UTC + 1:00)
    System Uptime: 0 days 14:59:40.140
    Process Uptime: 0 days 3:08:03.000
    ................................................................
    .....................
    eax=00000000 ebx=00128094 ecx=0012804c edx=7c90e514 esi=00000000 edi=7ffd5000
    eip=7c90e514 esp=0012806c ebp=00128108 iopl=0         nv up ei pl zr na pe nc
    cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00200246
    ntdll!KiFastSystemCallRet:
    7c90e514 c3              ret
    0:000> !analyze -v; .ecxr;
    *******************************************************************************
    *                                                                             *
    *                        Exception Analysis                                   *
    *                                                                             *
    *******************************************************************************

    *** WARNING: Unable to verify checksum for mscorlib.ni.dll
    *** WARNING: Unable to verify checksum for System.Windows.Forms.ni.dll
    *** WARNING: Unable to verify checksum for System.ni.dll
    Unable to load image C:\EPOS\ipworksssl9.dll, Win32 error 0n2
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for ipworksssl9.dll - 
    Unable to load image C:\AppPath\My_C_Application.exe, Win32 error 0n2
    *** WARNING: Unable to verify checksum for My_C_Application.exe
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for My_C_Application.exe - 
    *** ERROR: Module load completed but symbols could not be loaded for xpsp2res.dll
    GetPageUrlData failed, server returned HTTP status 404
    URL requested: http://watson.microsoft.com/StageOne/My_C_Application_exe/0_0_0_0/unknown/0_0_0_0/00000000.htm?Retriage=1

    FAULTING_IP: 
    +1562faf0007da9c
    00000000 ??              ???

    EXCEPTION_RECORD:  ffffffff -- (.exr 0xffffffffffffffff)
    .exr 0xffffffffffffffff
    ExceptionAddress: 00000000
       ExceptionCode: 80000003 (Break instruction exception)
      ExceptionFlags: 00000000
    NumberParameters: 0

    FAULTING_THREAD:  000020f8

    PROCESS_NAME:  My_C_Application.exe

    ERROR_CODE: (NTSTATUS) 0x80000003 - {EXCEPTION}  Breakpoint  A breakpoint has been reached.

    EXCEPTION_CODE: (HRESULT) 0x80000003 (2147483651) - One or more arguments are invalid

    MOD_LIST: <ANALYSIS/>

    NTGLOBALFLAG:  0

    APPLICATION_VERIFIER_FLAGS:  0

    MANAGED_STACK: !dumpstack -EE
    !dumpstack -EE
    No export dumpstack found

    LAST_CONTROL_TRANSFER:  from 7c90df4a to 7c90e514

    ADDITIONAL_DEBUG_TEXT:  Followup set based on attribute [Is_ChosenCrashFollowupThread] from Frame:[0] on thread:[PSEUDO_THREAD]

    DEFAULT_BUCKET_ID:  STACKIMMUNE

    PRIMARY_PROBLEM_CLASS:  STACKIMMUNE

    BUGCHECK_STR:  APPLICATION_FAULT_STACKIMMUNE_NOSOS_WRONG_SYMBOLS

    STACK_TEXT:  
    00000000 00000000 My_C_Application.exe+0x0


    STACK_COMMAND:  .cxr 00000000 ; kb ; ** Pseudo Context ** ; kb

    SYMBOL_NAME:  My_C_Application.exe

    FOLLOWUP_NAME:  MachineOwner

    MODULE_NAME: My_C_Application

    IMAGE_NAME:  My_C_Application.exe

    DEBUG_FLR_IMAGE_TIMESTAMP:  55b8bb1c

    FAILURE_BUCKET_ID:  STACKIMMUNE_80000003_My_C_Application.exe!Unknown

    BUCKET_ID:  APPLICATION_FAULT_STACKIMMUNE_NOSOS_WRONG_SYMBOLS_My_C_Application.exe

    FOLLOWUP_IP: 
    My_C_Application+0
    00400000 4d              dec     ebp

    WATSON_STAGEONE_URL:  http://watson.microsoft.com/StageOne/My_C_Application_exe/0_0_0_0/55b8bb1c/unknown/0_0_0_0/bbbbbbb4/80000003/00000000.htm?Retriage=1

    Followup: MachineOwner
    ---------

    Minidump doesn't have an exception context
    Unable to get exception context, HRESULT 0x80004002
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    0:000> .lastevent
    Last event: 1ee4.20f8: Break instruction exception - code 80000003 (first/second chance not available)
      debugger time: Tue Aug  4 12:40:51.455 2015 (UTC + 1:00)

我可以使用上述输出中的任何用途吗?

现在我们拥有的代码是在网站上运行的确切代码,然而EXE在另一台PC上重新构建以进行调试,因此符号似乎无法加载, 我们之前已经看过这个,所以我们执行以下命令:

    0:000> .symopt+0x80000000
    Symbol options are 0x800B0277:
      0x00000001 - SYMOPT_CASE_INSENSITIVE
      0x00000002 - SYMOPT_UNDNAME
      0x00000004 - SYMOPT_DEFERRED_LOADS
      0x00000010 - SYMOPT_LOAD_LINES
      0x00000020 - SYMOPT_OMAP_FIND_NEAREST
      0x00000040 - SYMOPT_LOAD_ANYTHING
      0x00000200 - SYMOPT_FAIL_CRITICAL_ERRORS
      0x00010000 - SYMOPT_AUTO_PUBLICS
      0x00020000 - SYMOPT_NO_IMAGE_SEARCH
      0x00080000 - SYMOPT_NO_PROMPTS
      0x80000000 - SYMOPT_DEBUG
    0:000> .reload -f -i My_C_Application.exe=00400000
    DBGHELP: C:\crash\AutomateCrashAnalysis\AutomateCrashAnalysis\bin\Debug\My_C_Application___Win32_Debug\My_C_Application.exe - OK
    DBGENG:  C:\crash\AutomateCrashAnalysis\AutomateCrashAnalysis\bin\Debug\My_C_Application___Win32_Debug\My_C_Application.exe - Mapped image memory
    DBGHELP: My_C_Application - private symbols & lines 
             c:\crash\automatecrashanalysis\automatecrashanalysis\bin\debug\My_C_Application___win32_debug\My_C_Application.pdb
    0:000> lme
    start    end        module name
    00400000 013ec000   My_C_Application C (private pdb symbols)  c:\crash\automatecrashanalysis\automatecrashanalysis\bin\debug\My_C_Application___win32_debug\My_C_Application.pdb
    790c0000 79bba000   mscorlib_ni C (deferred)             
    7a440000 7abdf000   System_ni C (deferred)             
    7afd0000 7bbaf000   System_Windows_Forms_ni C (deferred)           

现在我们应该正确加载符号,如果我执行kv,我们会看到以下内容:

    0:000> kv
    ChildEBP RetAddr  Args to Child              
    00128068 7c90df4a 7c809590 00000002 00128094 ntdll!KiFastSystemCallRet (FPO: [0,0,0])
    0012806c 7c809590 00000002 00128094 00000001 ntdll!ZwWaitForMultipleObjects+0xc (FPO: [5,0,0])
    00128108 7e4195f9 00000002 00128130 00000000 kernel32!WaitForMultipleObjectsEx+0x12c (FPO: [Non-Fpo])
    00128164 7752e78e 00000001 00128464 000003e8 user32!RealMsgWaitForMultipleObjectsEx+0x13e (FPO: [Non-Fpo])
    0012818c 775572af 00128464 000003e8 001281b8 ole32!CCliModalLoop::BlockFn+0x80 (FPO: [Non-Fpo])
    00128200 79fd05fd 00000002 000003e8 00000001 ole32!CoWaitForMultipleHandles+0xcf (FPO: [Non-Fpo])
    00128220 79fd0564 00000000 000003e8 00000001 mscorwks!NT5WaitRoutine+0x51 (FPO: [Non-Fpo])
    0012828c 79fd04c8 00000001 00128464 00000000 mscorwks!MsgWaitHelper+0xa5 (FPO: [Non-Fpo])
    001282ac 79f6915d 00000001 00128464 00000001 mscorwks!Thread::DoAppropriateAptStateWait+0x28 (FPO: [Non-Fpo])
    00128330 79f691f2 00000001 00128464 00000001 mscorwks!Thread::DoAppropriateWaitWorker+0x13c (FPO: [Non-Fpo])
    00128380 79f99d40 00000001 00128464 00000001 mscorwks!Thread::DoAppropriateWait+0x40 (FPO: [Non-Fpo])
    00128484 792b698f 00000000 00000000 03d5bbec mscorwks!WaitHandleNative::CorWaitOneNative+0x156 (FPO: [Non-Fpo])
    001284a0 792b6945 000003e8 00000000 79317b08 mscorlib_ni+0x1f698f
    001284b8 7b6f218f 00000000 00000103 0000c121 mscorlib_ni+0x1f6945
    001284d0 7ba2e34b a92aae2d 79e749d8 00128668 System_Windows_Forms_ni+0x72218f
    00128564 7b6f3aec 00000001 03d5bbd8 03d5bbb8 System_Windows_Forms_ni+0xa5e34b
    001285a0 7b921b1b 03d5bbd8 03d5bbd8 03d5bbb8 System_Windows_Forms_ni+0x723aec
    001285b8 7a932cb6 03d5ac5c 03c2d938 00000001 System_Windows_Forms_ni+0x951b1b
    001285ec 7a930e6f 03d5ac5c ffffffff 00000000 System_ni+0x4f2cb6
    00128638 7a93205f 03d5ac5c 00000009 00000000 System_ni+0x4f0e6f
    00128654 7aaa767a 001fab80 00000001 a92aae2d System_ni+0x4f205f
    001286e4 7e418734 000c00be 0000201a 00000001 System_ni+0x66767a
    00128710 7e418816 030b7392 000c00be 0000201a user32!InternalCallWinProc+0x28
    00128778 7e4189cd 00000000 030b7392 000c00be user32!UserCallWinProcCheckWow+0x150 (FPO: [Non-Fpo])
    001287d8 7e4196c7 00128800 00000001 0012881c user32!DispatchMessageWorker+0x306 (FPO: [Non-Fpo])
    001287e8 1001d222 00128800 00000000 00165008 user32!DispatchMessageA+0xf (FPO: [Non-Fpo])
    WARNING: Stack unwind information not available. Following frames may be wrong.
    0012881c 1007f803 00000014 00040232 100a1e04 ipworksssl9+0x1d222
    001288f4 009d259f 00128924 00e238ae 00000000 ipworksssl9+0x7f803
    00000000 00000000 00000000 00000000 00000000 My_C_Application!sprintf+0x9f (CONV: cdecl) [sprintf.c @ 104]

WaitForMultipleObjects是否指示死锁(等待Lock / CriticalSection / Mutex)??

我原本期望在My_C_Application中看到一个while循环,但我没有,我跑〜* kp但这些线程似乎都没有在My_C_Application中循环或锁定。

    :000> ~* kp

    .  0  Id: 1ee4.20f8 Suspend: 0 Teb: 7ffdf000 Unfrozen
    ChildEBP RetAddr  
    00128068 7c90df4a ntdll!KiFastSystemCallRet
    0012806c 7c809590 ntdll!ZwWaitForMultipleObjects+0xc
    00128108 7e4195f9 kernel32!WaitForMultipleObjectsEx+0x12c
    00128164 7752e78e user32!RealMsgWaitForMultipleObjectsEx+0x13e
    0012818c 775572af ole32!CCliModalLoop::BlockFn+0x80
    00128200 79fd05fd ole32!CoWaitForMultipleHandles+0xcf
    00128220 79fd0564 mscorwks!NT5WaitRoutine+0x51
    0012828c 79fd04c8 mscorwks!MsgWaitHelper+0xa5
    001282ac 79f6915d mscorwks!Thread::DoAppropriateAptStateWait+0x28
    00128330 79f691f2 mscorwks!Thread::DoAppropriateWaitWorker+0x13c
    00128380 79f99d40 mscorwks!Thread::DoAppropriateWait+0x40
    00128484 792b698f mscorwks!WaitHandleNative::CorWaitOneNative+0x156
    001284a0 792b6945 mscorlib_ni+0x1f698f
    001284b8 7b6f218f mscorlib_ni+0x1f6945
    001284d0 7ba2e34b System_Windows_Forms_ni+0x72218f
    00128564 7b6f3aec System_Windows_Forms_ni+0xa5e34b
    001285a0 7b921b1b System_Windows_Forms_ni+0x723aec
    001285b8 7a932cb6 System_Windows_Forms_ni+0x951b1b
    001285ec 7a930e6f System_ni+0x4f2cb6
    00128638 7a93205f System_ni+0x4f0e6f
    00128654 7aaa767a System_ni+0x4f205f
    001286e4 7e418734 System_ni+0x66767a
    00128710 7e418816 user32!InternalCallWinProc+0x28
    00128778 7e4189cd user32!UserCallWinProcCheckWow+0x150
    001287d8 7e4196c7 user32!DispatchMessageWorker+0x306
    001287e8 1001d222 user32!DispatchMessageA+0xf
    WARNING: Stack unwind information not available. Following frames may be wrong.
    0012881c 1007f803 ipworksssl9+0x1d222
    001288f4 009d259f ipworksssl9+0x7f803
    00000000 00000000 My_C_Application!sprintf(char * string = <Memory access error>, char * format = <Memory access error>)+0x9f [sprintf.c @ 104]

       1  Id: 1ee4.2364 Suspend: 0 Teb: 7ffdd000 Unfrozen
    ChildEBP RetAddr  
    01edfe64 7e4191be ntdll!KiFastSystemCallRet
    01edfe8c 00986a0f user32!NtUserGetMessage+0xc
    01edff80 009867d8 My_C_Application!WMConnection::threadFunc(void)+0x20a [C:\Code\BuildFolder\My_C_Application\SourcePath\WMConnection.cpp @ 139]
    01edffb4 7c80b729 My_C_Application!wmConnectionThreadFunc(void * lpData = 0x01d5b970)+0x62 [C:\Code\BuildFolder\My_C_Application\SourcePath\WMConnection.cpp @ 80]
    01edffec 00000000 kernel32!BaseThreadStart+0x37

       2  Id: 1ee4.204c Suspend: 0 Teb: 7ffdc000 Unfrozen
    ChildEBP RetAddr  
    0214fecc 7c90df4a ntdll!KiFastSystemCallRet
    0214fed0 7c809590 ntdll!ZwWaitForMultipleObjects+0xc
    0214ff6c 7c80a115 kernel32!WaitForMultipleObjectsEx+0x12c
    0214ff88 72d2312a kernel32!WaitForMultipleObjects+0x18
    0214ffb4 7c80b729 wdmaud!MixerCallbackThread+0x42
    0214ffec 00000000 kernel32!BaseThreadStart+0x37

       3  Id: 1ee4.210c Suspend: 0 Teb: 7ffdb000 Unfrozen
    ChildEBP RetAddr  
    0224fd84 7c90df4a ntdll!KiFastSystemCallRet
    0224fd88 7c809590 ntdll!ZwWaitForMultipleObjects+0xc
    0224fe24 7c80a115 kernel32!WaitForMultipleObjectsEx+0x12c
    0224fe40 73f114a2 kernel32!WaitForMultipleObjects+0x18
    0224fe58 73f12862 dsound!WaitObjectArray+0x17
    0224ff78 73f198df dsound!CThread::TpWaitObjectArray+0x51
    0224ff98 73f12896 dsound!CCallbackEventPool::ThreadProc+0x1a
    0224ffa4 73f1b2e9 dsound!CThread::ThreadLoop+0x1d
    0224ffac 73f1b2ae dsound!CThread::PrivateThreadProc+0x32
    0224ffb4 7c80b729 dsound!CThread::ThreadStartRoutine+0xd
    0224ffec 00000000 kernel32!BaseThreadStart+0x37

       4  Id: 1ee4.2344 Suspend: 0 Teb: 7ffda000 Unfrozen
    ChildEBP RetAddr  
    0244fd8c 7c90df4a ntdll!KiFastSystemCallRet
    0244fd90 7c809590 ntdll!ZwWaitForMultipleObjects+0xc
    0244fe2c 7c80a115 kernel32!WaitForMultipleObjectsEx+0x12c
    0244fe48 73f114a2 kernel32!WaitForMultipleObjects+0x18
    0244fe60 73f12862 dsound!WaitObjectArray+0x17
    0244ff80 73f1292b dsound!CThread::TpWaitObjectArray+0x51
    0244ff98 73f12896 dsound!CDirectSoundAdministrator::ThreadProc+0x16
    0244ffa4 73f1b2e9 dsound!CThread::ThreadLoop+0x1d
    0244ffac 73f1b2ae dsound!CThread::PrivateThreadProc+0x32
    0244ffb4 7c80b729 dsound!CThread::ThreadStartRoutine+0xd
    0244ffec 00000000 kernel32!BaseThreadStart+0x37

       5  Id: 1ee4.22d8 Suspend: 0 Teb: 7ffd9000 Unfrozen
    ChildEBP RetAddr  
    0256ff08 7c90df5a ntdll!KiFastSystemCallRet
    0256ff0c 7c8025db ntdll!NtWaitForSingleObject+0xc
    0256ff70 7c802542 kernel32!WaitForSingleObjectEx+0xa8
    0256ff84 5c57ae32 kernel32!WaitForSingleObject+0x12
    0256ffac 5c57bec0 dmime!CPerformance::Realtime+0x127
    0256ffb4 7c80b729 dmime!CPerformance::Release+0x94
    0256ffec 00000000 kernel32!BaseThreadStart+0x37

       6  Id: 1ee4.2190 Suspend: 0 Teb: 7ffd8000 Unfrozen
    ChildEBP RetAddr  
    0266feec 7c90df5a ntdll!KiFastSystemCallRet
    0266fef0 7c8025db ntdll!NtWaitForSingleObject+0xc
    0266ff54 7c802542 kernel32!WaitForSingleObjectEx+0xa8
    0266ff68 5c57effc kernel32!WaitForSingleObject+0x12
    0266ffac 5c57f04d dmime!CPerformance::Transport+0x47d
    0266ffb4 7c80b729 dmime!CPerformance::Transport+0x4ce
    0266ffec 00000000 kernel32!BaseThreadStart+0x37

       7  Id: 1ee4.1dfc Suspend: 0 Teb: 7ffd7000 Unfrozen
    ChildEBP RetAddr  
    029dff10 7c90df5a ntdll!KiFastSystemCallRet
    029dff14 7c8025db ntdll!NtWaitForSingleObject+0xc
    029dff78 7c802542 kernel32!WaitForSingleObjectEx+0xa8
    029dff8c 6c9ae4b5 kernel32!WaitForSingleObject+0x12
    029dffac 6c9ae4ed dmsynth!CDSLinkList::SynthProc+0x95
    029dffb4 7c80b729 dmsynth!CDSLinkList::SynthProc+0xcd
    029dffec 00000000 kernel32!BaseThreadStart+0x37

       8  Id: 1ee4.2778 Suspend: 0 Teb: 7ffd6000 Unfrozen
    ChildEBP RetAddr  
    02adff78 7c90da4a ntdll!KiFastSystemCallRet
    02adff7c 71a5d320 ntdll!NtRemoveIoCompletion+0xc
    02adffb4 7c80b729 mswsock!SockAsyncThread+0x5a
    02adffec 00000000 kernel32!BaseThreadStart+0x37

       9  Id: 1ee4.2188 Suspend: 0 Teb: 7ffd4000 Unfrozen
    ChildEBP RetAddr  
    02eafce8 7c90df4a ntdll!KiFastSystemCallRet
    02eafcec 7c92a51a ntdll!ZwWaitForMultipleObjects+0xc
    02eaffb4 7c80b729 ntdll!RtlpWaitThread+0x13d
    02eaffec 00000000 kernel32!BaseThreadStart+0x37

      10  Id: 1ee4.ee0 Suspend: 0 Teb: 7ffaf000 Unfrozen
    ChildEBP RetAddr  
    02fafec8 7c90df4a ntdll!KiFastSystemCallRet
    02fafecc 7c809590 ntdll!ZwWaitForMultipleObjects+0xc
    02faff68 7c80a115 kernel32!WaitForMultipleObjectsEx+0x12c
    02faff84 769c87bd kernel32!WaitForMultipleObjects+0x18
    02faffb4 7c80b729 userenv!NotificationThread+0x5f
    02faffec 00000000 kernel32!BaseThreadStart+0x37

      11  Id: 1ee4.26b4 Suspend: 0 Teb: 7ffae000 Unfrozen
    ChildEBP RetAddr  
    0333fe38 7c90df4a ntdll!KiFastSystemCallRet
    0333fe3c 7c809590 ntdll!ZwWaitForMultipleObjects+0xc
    0333fed8 7c80a115 kernel32!WaitForMultipleObjectsEx+0x12c
    0333fef4 79f86a21 kernel32!WaitForMultipleObjects+0x18
    0333ff54 79f8697e mscorwks!DebuggerRCThread::MainLoop+0xe9
    0333ff84 79f868a5 mscorwks!DebuggerRCThread::ThreadProc+0xe5
    0333ffb4 7c80b729 mscorwks!DebuggerRCThread::ThreadProcStatic+0x9c
    0333ffec 00000000 kernel32!BaseThreadStart+0x37

      12  Id: 1ee4.bc8 Suspend: 0 Teb: 7ffad000 Unfrozen
    ChildEBP RetAddr  
    034ffcd0 7c90df4a ntdll!KiFastSystemCallRet
    034ffcd4 7c809590 ntdll!ZwWaitForMultipleObjects+0xc
    034ffd70 7c80a115 kernel32!WaitForMultipleObjectsEx+0x12c
    034ffd8c 79fc5107 kernel32!WaitForMultipleObjects+0x18
    034ffdac 79fc9568 mscorwks!WKS::WaitForFinalizerEvent+0x77
    034ffdc0 79e9b08f mscorwks!WKS::GCHeap::FinalizerThreadWorker+0x49
    034ffdd4 79e9b02b mscorwks!Thread::DoADCallBack+0x32a
    034ffe68 79e9af51 mscorwks!Thread::ShouldChangeAbortToUnload+0xe3
    034ffea4 79f73514 mscorwks!Thread::ShouldChangeAbortToUnload+0x30a
    034ffecc 79f73525 mscorwks!ManagedThreadBase_NoADTransition+0x32
    034ffedc 79fc019c mscorwks!ManagedThreadBase::FinalizerBase+0xd
    034fff14 79fc4551 mscorwks!WKS::GCHeap::FinalizerThreadStart+0xbb
    034fffb4 7c80b729 mscorwks!Thread::intermediateThreadProc+0x49
    034fffec 00000000 kernel32!BaseThreadStart+0x37

      13  Id: 1ee4.23b8 Suspend: 0 Teb: 7ffaa000 Unfrozen
    ChildEBP RetAddr  
    03abfee4 7c90df5a ntdll!KiFastSystemCallRet
    03abfee8 7c8025db ntdll!NtWaitForSingleObject+0xc
    03abff4c 7c802542 kernel32!WaitForSingleObjectEx+0xa8
    03abff60 009a6408 kernel32!WaitForSingleObject+0x12
    03abff7c 009dc2d7 My_C_Application!file4writeDelayMain+0x38
    03abffb4 7c80b729 My_C_Application!_threadstart(void * ptd = 0x01d5fa50)+0xa7 [thread.c @ 187]
    03abffec 00000000 kernel32!BaseThreadStart+0x37

      14  Id: 1ee4.fa8 Suspend: 0 Teb: 7ffa9000 Unfrozen
    ChildEBP RetAddr  
    05c6fee4 7c90df5a ntdll!KiFastSystemCallRet
    05c6fee8 7c8025db ntdll!NtWaitForSingleObject+0xc
    05c6ff4c 7c802542 kernel32!WaitForSingleObjectEx+0xa8
    05c6ff60 009a8128 kernel32!WaitForSingleObject+0x12
    05c6ff7c 009dc2d7 My_C_Application!file4advanceReadMain+0x38
    05c6ffb4 7c80b729 My_C_Application!_threadstart(void * ptd = 0x01d5faf8)+0xa7 [thread.c @ 187]
    05c6ffec 00000000 kernel32!BaseThreadStart+0x37

      15  Id: 1ee4.b0 Suspend: 0 Teb: 7ffa8000 Unfrozen
    ChildEBP RetAddr  
    05d6fed4 7c90df5a ntdll!KiFastSystemCallRet
    05d6fed8 7c8025db ntdll!NtWaitForSingleObject+0xc
    05d6ff3c 7c802542 kernel32!WaitForSingleObjectEx+0xa8
    05d6ff50 77596f14 kernel32!WaitForSingleObject+0x12
    05d6ff6c 77567135 ole32!CDllHost::MTAWorkerLoop+0x2b
    05d6ff8c 775263f4 ole32!CDllHost::WorkerThread+0xc1
    05d6ff94 774fe4ba ole32!DLLHostThreadEntry+0xd
    05d6ffa8 774fe522 ole32!CRpcThread::WorkerLoop+0x1e
    05d6ffb4 7c80b729 ole32!CRpcThreadCache::RpcWorkerThreadEntry+0x1b
    05d6ffec 00000000 kernel32!BaseThreadStart+0x37

      16  Id: 1ee4.232c Suspend: 0 Teb: 7ffa5000 Unfrozen
    ChildEBP RetAddr  
    0df8fa74 7c90d21a ntdll!KiFastSystemCallRet
    0df8fa78 7c8023f1 ntdll!NtDelayExecution+0xc
    0df8fad0 7c802455 kernel32!SleepEx+0x61
    0df8fae0 005594cf kernel32!Sleep+0xf
    0df8ff7c 009dc2d7 My_C_Application!Read_FPs_Thread(void * pvoid = 0x00ecb058)+0x888 [C:\Code\BuildFolder\My_C_Application\SourcePath\cbe_pump.cpp @ 2085]
    0df8ffb4 7c80b729 My_C_Application!_threadstart(void * ptd = 0x02fc6018)+0xa7 [thread.c @ 187]
    0df8ffec 00000000 kernel32!BaseThreadStart+0x37

      17  Id: 1ee4.2590 Suspend: 0 Teb: 7ffa7000 Unfrozen
    ChildEBP RetAddr  
    05e6fe14 7c90daaa ntdll!KiFastSystemCallRet
    05e6fe18 77e765e3 ntdll!NtReplyWaitReceivePortEx+0xc
    05e6ff80 77e76caf rpcrt4!LRPC_ADDRESS::ReceiveLotsaCalls+0x12a
    05e6ff88 77e76ad1 rpcrt4!RecvLotsaCallsWrapper+0xd
    05e6ffa8 77e76c97 rpcrt4!BaseCachedThreadRoutine+0x79
    05e6ffb4 7c80b729 rpcrt4!ThreadStartRoutine+0x1a
    05e6ffec 00000000 kernel32!BaseThreadStart+0x37

      18  Id: 1ee4.1b54 Suspend: 0 Teb: 7ffa6000 Unfrozen
    ChildEBP RetAddr  
    0e22fe50 7c90df4a ntdll!KiFastSystemCallRet
    0e22fe54 7c809590 ntdll!ZwWaitForMultipleObjects+0xc
    0e22fef0 7e4195f9 kernel32!WaitForMultipleObjectsEx+0x12c
    0e22ff4c 7e4196a8 user32!RealMsgWaitForMultipleObjectsEx+0x13e
    0e22ff68 4ec674b2 user32!MsgWaitForMultipleObjects+0x1f
    0e22ffb4 7c80b729 GdiPlus!BackgroundThreadProc+0x59
    0e22ffec 00000000 kernel32!BaseThreadStart+0x37

      19  Id: 1ee4.23bc Suspend: 0 Teb: 7ffa4000 Unfrozen
    ChildEBP RetAddr  
    0e84f6d8 7c90d21a ntdll!KiFastSystemCallRet
    0e84f6dc 7c8023f1 ntdll!NtDelayExecution+0xc
    0e84f734 79e889d8 kernel32!SleepEx+0x61
    0e84f768 79f0e0b8 mscorwks!EESleepEx+0xbb
    0e84f778 79f0e0a6 mscorwks!CExecutionEngine::ClrSleepEx+0xe
    0e84f78c 79f0e065 mscorwks!ClrSleepEx+0x14
    0e84f7c8 79f0e166 mscorwks!Thread::UserSleep+0x63
    0e84f868 0e3af62b mscorwks!ThreadNative::Sleep+0xce
    WARNING: Frame IP not in any known module. Following frames may be wrong.
    0e84f8b8 792d7026 0xe3af62b
    0e84f8c4 792e04af mscorlib_ni+0x217026
    0e84f8d8 792d6fa4 mscorlib_ni+0x2204af
    0e84f8f0 79e71b4c mscorlib_ni+0x216fa4
    0e84f900 79e88e45 mscorwks!CallDescrWorker+0x33
    0e84f980 79e96461 mscorwks!CallDescrWorkerWithHandler+0xa3
    0e84fab8 79e96494 mscorwks!MethodDesc::CallDescr+0x19c
    0e84fad4 79e964b2 mscorwks!MethodDesc::CallTargetWorker+0x1f
    0e84faec 79f0f9b7 mscorwks!MethodDescCallSite::CallWithValueTypes_RetArgSlot+0x1a
    0e84fcd4 79e9b08f mscorwks!ThreadNative::KickOffThread_Worker+0x192
    0e84fce8 79e9b02b mscorwks!Thread::DoADCallBack+0x32a
    0e84fd7c 79e9af51 mscorwks!Thread::ShouldChangeAbortToUnload+0xe3
    0e84fdb8 79e9b0dd mscorwks!Thread::ShouldChangeAbortToUnload+0x30a
    0e84fde0 79f0f788 mscorwks!Thread::ShouldChangeAbortToUnload+0x33e
    0e84fdf8 79f0f862 mscorwks!ManagedThreadBase::KickOff+0x13
    0e84fe94 79fc4551 mscorwks!ThreadNative::KickOffThread+0x269
    0e84ffb4 7c80b729 mscorwks!Thread::intermediateThreadProc+0x49
    0e84ffec 00000000 kernel32!BaseThreadStart+0x37

      20  Id: 1ee4.27c8 Suspend: 0 Teb: 7ffa2000 Unfrozen
    ChildEBP RetAddr  
    0eb0fed0 7c90d21a ntdll!KiFastSystemCallRet
    0eb0fed4 7c8023f1 ntdll!NtDelayExecution+0xc
    0eb0ff2c 79ee7c61 kernel32!SleepEx+0x61
    0eb0ffa8 79ee7b0f mscorwks!ThreadpoolMgr::TimerThreadFire+0x6d
    0eb0ffb4 7c80b729 mscorwks!ThreadpoolMgr::TimerThreadStart+0x57
    0eb0ffec 00000000 kernel32!BaseThreadStart+0x37

      21  Id: 1ee4.2710 Suspend: 0 Teb: 7ffa1000 Unfrozen
    ChildEBP RetAddr  
    0e5cff10 7e4191be ntdll!KiFastSystemCallRet
    0e5cff30 7752ffc6 user32!NtUserGetMessage+0xc
    0e5cff70 775264c1 ole32!CDllHost::STAWorkerLoop+0x72
    0e5cff8c 775263f4 ole32!CDllHost::WorkerThread+0xc8
    0e5cff94 774fe4ba ole32!DLLHostThreadEntry+0xd
    0e5cffa8 774fe522 ole32!CRpcThread::WorkerLoop+0x1e
    0e5cffb4 7c80b729 ole32!CRpcThreadCache::RpcWorkerThreadEntry+0x1b
    0e5cffec 00000000 kernel32!BaseThreadStart+0x37

      22  Id: 1ee4.2530 Suspend: 0 Teb: 7ffde000 Unfrozen
    ChildEBP RetAddr  
    01c4fd74 7c90da4a ntdll!KiFastSystemCallRet
    01c4fd78 7c80a7e6 ntdll!NtRemoveIoCompletion+0xc
    01c4fda4 79f65810 kernel32!GetQueuedCompletionStatus+0x29
    01c4fe14 79fc4551 mscorwks!ThreadpoolMgr::CompletionPortThreadStart+0x141
    01c4ffb4 7c80b729 mscorwks!Thread::intermediateThreadProc+0x49
    01c4ffec 00000000 kernel32!BaseThreadStart+0x37

我是否可以运行任何其他命令来确定在My_C_Application中调用此锁定/循环的位置?

加法:

根据EdChum的要求,我们不会等待任何锁定

    0:000> !cs -s -l -o
    -----------------------------------------
    DebugInfo          = 0x0016eea8
    Critical section   = 0x01d59c60 (+0x1D59C60)
    LOCKED
    LockCount          = 0x0
    OwningThread       = 0x000020f8
    RecursionCount     = 0x1
    LockSemaphore      = 0x0
    SpinCount          = 0x00000000
    OwningThread DbgId = ~0s
    OwningThread Stack =
        ChildEBP RetAddr  Args to Child              
        00128068 7c90df4a 7c809590 00000002 00128094 ntdll!KiFastSystemCallRet (FPO: [0,0,0])
        0012806c 7c809590 00000002 00128094 00000001 ntdll!ZwWaitForMultipleObjects+0xc (FPO: [5,0,0])
        00128108 7e4195f9 00000002 00128130 00000000 kernel32!WaitForMultipleObjectsEx+0x12c (FPO: [Non-Fpo])
        00128164 7752e78e 00000001 00128464 000003e8 user32!RealMsgWaitForMultipleObjectsEx+0x13e (FPO: [Non-Fpo])
        0012818c 775572af 00128464 000003e8 001281b8 ole32!CCliModalLoop::BlockFn+0x80 (FPO: [Non-Fpo])
        00128200 79fd05fd 00000002 000003e8 00000001 ole32!CoWaitForMultipleHandles+0xcf (FPO: [Non-Fpo])
        00128220 79fd0564 00000000 000003e8 00000001 mscorwks!NT5WaitRoutine+0x51 (FPO: [Non-Fpo])
        0012828c 79fd04c8 00000001 00128464 00000000 mscorwks!MsgWaitHelper+0xa5 (FPO: [Non-Fpo])
        001282ac 79f6915d 00000001 00128464 00000001 mscorwks!Thread::DoAppropriateAptStateWait+0x28 (FPO: [Non-Fpo])
        00128330 79f691f2 00000001 00128464 00000001 mscorwks!Thread::DoAppropriateWaitWorker+0x13c (FPO: [Non-Fpo])
        00128380 79f99d40 00000001 00128464 00000001 mscorwks!Thread::DoAppropriateWait+0x40 (FPO: [Non-Fpo])
        00128484 792b698f 00000000 00000000 03d5bbec mscorwks!WaitHandleNative::CorWaitOneNative+0x156 (FPO: [Non-Fpo])
        001284a0 792b6945 000003e8 00000000 79317b08 mscorlib_ni+0x1f698f
        001284b8 7b6f218f 00000000 00000103 0000c121 mscorlib_ni+0x1f6945
        001284d0 7ba2e34b a92aae2d 79e749d8 00128668 System_Windows_Forms_ni+0x72218f
        00128564 7b6f3aec 00000001 03d5bbd8 03d5bbb8 System_Windows_Forms_ni+0xa5e34b
        001285a0 7b921b1b 03d5bbd8 03d5bbd8 03d5bbb8 System_Windows_Forms_ni+0x723aec
        001285b8 7a932cb6 03d5ac5c 03c2d938 00000001 System_Windows_Forms_ni+0x951b1b
        001285ec 7a930e6f 03d5ac5c ffffffff 00000000 System_ni+0x4f2cb6
        00128638 7a93205f 03d5ac5c 00000009 00000000 System_ni+0x4f0e6f
    ntdll!RtlpStackTraceDataBase is NULL. Probably the stack traces are not enabled.

先谢谢

1 个答案:

答案 0 :(得分:0)

从您展示的内容来看,您的消息循环似乎已陷入僵局。

首先要认识到的是,当你看到这样的帧时:

mscorlib_ni+0x1f698f
mscorlib_ni+0x1f6945
System_ni+0x4f2cb6

这是来自您的应用程序的jitted托管代码,您不会拥有正常的符号,因为代码会在运行时生成并放置在那里。您可以使用!ip2md mscorlib_ni+0x1f698f(加载SOS后)查看托管函数名称。查看jitted框架将有助于“我没有看到我的任何代码运行&#34; (就是这样,它显然不是很明显)。

看看这个堆栈,突然出现的是对DispatchMessage()的调用,它在标准的消息循环中使用,然后调用你的应用程序代码(完全可以预料)来处理消息,但后来有一个WaitOne被叫。您需要检查代码以查看您正在等待的事件。如果无法处理其他消息,很可能正在等待无法发出信号的内容。

mscorwks!WaitHandleNative::CorWaitOneNative+0x156 (FPO: [Non-Fpo])
mscorlib_ni+0x1f698f <<<<<< look here
... jitted app code ...
user32!InternalCallWinProc+0x28
user32!UserCallWinProcCheckWow+0x150 (FPO: [Non-Fpo])
user32!DispatchMessageWorker+0x306 (FPO: [Non-Fpo])
user32!DispatchMessageA+0xf (FPO: [Non-Fpo])
...