질문하기질문하기
 

질문Windows Service Crashes and JIT debug

  • 2009년 6월 4일 목요일 오후 11:52webcliff2 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    All,

    Sorry, this is not a short post, english is not my native language, if I confuse you, please ask, I will try to explain.

    My Windows Service  (myservice.exe) is based on .NET 2.0 framework (x86 32bit XP SP2), it uses threading and remoting, sometimes crashes.
    When it crashes, I could found a log event from event viewer, sometimes I could not.

    ==============
    Event Type: Error
    Event Source: .NET Runtime 2.0 Error Reporting
    Event Category: None
    Event ID: 5000
    Date:  5/30/2009
    Time:  7:46:40 AM
    User:  N/A
    Computer: OEM-IDKVIEBJAWI
    Description:
    EventType clr20r3, P1 myservice.exe, P2 1.0.5.74, P3 4a121d7c, P4 mscorlib, P5 2.0.0.0, P6 471ebc5b, P7 1937, P8 0, P9 system.indexoutofrangeexception, P10 NIL.
    ==============

    I have been trying to setup the registry to capture a memory dump, for example, I use these seetings:

    (I use windbg version 6.11.0001 x86 32bit)

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework]
    "DbgManagedDebugger"="\"C:\\Program Files\\Debugging Tools for Windows\\cdb.exe\" -pv -p %ld -c \".dump /u /ma c:\\crashdump.dmp;.kill;qd\""
    "DbgJITDebugLaunchSetting"=dword:00000002

    It works with my test managed console application and winform application, their crash all create dump files.

    BUT, no matter how I try, I just could not get these settings to work with windows service (myservice.exe)


    Here are my questions:

    1.Who add the log entry to windows event viewer, why sometimes it is there and sometimes it is not when myservice.exe crashes?

    2.How do I capture the randomly crashing myservice.exe's memory dump?

    3.Why the current registry setting does not work?

    • 편집됨webcliff2 2009년 6월 5일 금요일 오후 6:21meanful title
    • 편집됨webcliff2 2009년 6월 4일 목요일 오후 11:53os version
    •  

모든 응답

  • 2009년 6월 5일 금요일 오후 2:02p.b.a 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    When your service starts register for the AppDomain UnhandledException event and do you own logging - this way you have control over what's logged. Without knowing what the how the service works if you don't see any entry in the event log maybe it did not crash, it just terminated for whatever reason.

    Have you tried using AeDebug registry key instead of DbgManagedDebugger ? (http://technet.microsoft.com/en-us/library/cc738371(WS.10).aspx).
  • 2009년 6월 5일 금요일 오후 5:39webcliff2 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    p.b.a.

    Thanks for help!

    I did run drwtsn32 -i (Dr Watson, it sets AeDebug registry key ) and configure Dr Watson to capture all un-managed process crashes.
    It did not help with myservice.exe crash, I am assuming it is because myservice.exe is a managed windows service.

    Unfortunately I do not have access to source code , can't take AppDomain.UnhandledException approach.

    • 편집됨webcliff2 2009년 6월 5일 금요일 오후 5:41missing words
    •  
  • 2009년 6월 8일 월요일 오후 7:52Jon LangdonMSFT, 소유자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    A few questions:

    What version of the the CLR are you using (version of c:\windows\microsoft.net\framework\v2.0.50727\mscorwks.dll will be sufficient)?
    What account is the service running as?
    Is the service interactive? I.e. does it have UI (even if it's just a console window)?

    Something to try in order to narrow down the point of failure:
    Can you remove the commands from your DbgManagedDebugger registration? I.e. just set it to "C:\program files\debugging tools for windows\cdb.exe" -pv -p %ld and see if the debugger is launched. If your service is non-interactive you won't see any debugger UI, so just check task manager and see if cdb.exe is running.

    If that works we'll see if we can figure out why the command(s) are failing.

    If that doesn't work can you provide a simple repro? Simplify the service code as much as possible and let us know how you're installing it.

    Regards,
    Jon

  • 2009년 6월 9일 화요일 오후 7:13webcliff2 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Jon,

    Thanks for help!

    I have different versions of CLR (2.0 and 3.0) installed, myservice.exe was built with 2.0, and looks like it is loading C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll ( reported by Process Explorer)
    It uses "Local System" account and the service is not interactive <- I think, how do I check?

    Setting DbgManagedDebugger to "C:\program files\debugging tools for windows\cdb.exe" -pv -p %ld didn't fix the issue, I can not find any cdb.exe process running.

    I am trying to see if I can create a simple repro.


    The strange thing is, I think I managed to get it to work at some point by checking "Allow service to interact with desktop" on myservice.exe's service property.  BUT today, checking the same checkbox does not work any more --> really confused by this one.

    Regards.

     
  • 2009년 6월 10일 수요일 오후 7:06webcliff2 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Okay, I think I figured out the strange error regarding to "Allow service to interact with desktop" option.
    It has a lot to do with multi-threading.

    Basically, thread 1 and thread 2 use the same code, they will be probably generating the same exception:
    thread 1 throws an exception which was caught by DbgManagedDebugger, DbgManagedDebugger starts to take over.... but almost at the same time, thread 2 throws a new exception - no sure how the new exception is going to affect the on-going taking-over process of DbgManagedDebugger, I think it ends both myservice process and cdb process - this explains why sometimes it works but sometimes it does not work.

    My problem has been sloved. thanks for help!

    There are still a few questions left though:
    1. Who add the log entry to windows event viewer, why sometimes it is there and sometimes it is not when myservice.exe crashes?
    2. "Allow service to interact with desktop" option fixed my problem, but I know very little about the reason why, is there any further reading about the difference between interactive app and non-interactive app? 
    • 편집됨webcliff2 2009년 6월 10일 수요일 오후 7:07typo
    •