Re: Need Help Debugging



Assuming you are at least on WinXp/Win2003, then AppVerifier
http://www.microsoft.com/downloads/details.aspx?familyid=BD02C19C-1250-433C-8C1B-2619BD93B3A2&displaylang=en
does a much better job to track Critical Section usage than other
home brewed components.
And, in any case, the OS, even without instrumentation, tracks critical
sections
for you (you can use !locks in any windbg|cdb|ntsd debugger, for example).
As far as debugging crashes in production environments,
you should learn how to set-up Corporate Wrror Reporting / WER,
or, you should use straight and plain ADPlus.VBS from the debugger package.
In any case, you will have a much better dump than Drtwtsn32.exe can
generate,
and, it will give you a much better idea of what's going on.

Once you have the minidump of your process, you
can load-it in windbg|cdb|ntsd and, after having set-up good symbols,
you can post to the newsgroup the output of `!analyze -f -v;r;~*kb`.

--

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Ben" <benm5678@xxxxxxxxx> wrote in message
news:1190733357.980856.22700@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Sep 25, 8:42 am, "Waleri Todorov" <this...@xxxxxxxxxxxxxxxx> wrote:
Dr. Watson can create a crash minidump, that can be used for postmortem
debuggin. It will take you to exact location of the crash. With debug
build of your code, you will be positioned to the crash location, with
debug info loaded, etc...



"Ben" <benm5...@xxxxxxxxx> wrote in
messagenews:1190649816.660022.162510@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have a non-managed c++ service that has a crash periodically.

I analyze the DrWatson dump and every time it seems to point to a
ntdll!RtlInitializeCriticalSectionAndSpinCount. I do use
CRITICAL_SECTIONS often throughout the code to manage access to the
variables, since it's a multi-threaded app.

Is there a certain rule of thumb when using Critical Sections to avoid
this ? I saw in MSDN they say to call
InitializeCriticalSectionAndSpinCount instead of just
InitializeCriticalSection in order to avoid memory resource exceptions
on pre-windows-XP systems... but our clients are XP, so I think i'm ok
with using InitializeCriticalSection. Maybe there's something more
recommended to use ?

In my searches, i'm seen some references to stack overflows... i'm not
too familiar with how to avoid it ? can someone offer some
guidance ? I know we use some string variables that can hold a few MB
of xml data... usually they are declared as an STL "string" and passed
as references. Do I need to use 'new' to allocate these large vars ?
does that avoid using the stack ?!?

Thanks for any tips!
ben- Hide quoted text -

- Show quoted text -

I do use DrWatson and set to generate a full dump with symbols. I'm
running 'release' code on my 90 user pilot group since the debug
version has a 30-40% cpu spike every 10 seconds when we enumerate
system procs. But I do have a PDB file generated and all the source
code for each version.

Had about 5 crashes this month all from different PCs, and in all of
them, when I looked at the call stack, it seems to have started with a
call to addToLog (a custom func we have to write to the eventviewer)
in order to log some exception that happened in a try{}catch(...){}
block. The first line of that function is MyEnterCriticalSection,
which is our custom CRITICAL_SECTION class. That's the last line in
my code that call stack leads me to... and the next functions i see in
the stack are usually EnterCriticalSection or
IntializeCriticalSection... but double-clicking on them doesn't lead
me inside my custom MyEnterCriticalSection function... anyone know
why ? I did a full re-build one time, and still didn't help...

btw, the MyEnterCriticalSection is part of a custom class I built to
help track CRITICAL_SECTION usage. So in my code, when i want to
protect a section, I call
MyEnterCriticalSection("NameOfCriticalSection",
"NameOfFunctionThatIsRequesting") -- then my custom function, looks up
if "NameOfSection" appears in the <map> object it uses to store the
CRITICAL_SECTION pointers. If it does, it calls EnterCriticalSection
on it, if it doesn't, it creates a new CRITICAL_SECTION pointer and
adds to the <map> as "NameOfSection", then initializes & enters it.
Every time it messes with the <map> it protects it with
EnterCriticalSection. The beautiful thing, is I can get a report of
every critical_section and see which function 'owns' it and at what
time it aquired it and also see which functions are requesting it
currently... it helped me debug deadlocks in minutes.



.



Relevant Pages

  • Re: Need Help Debugging
    ... you should use straight and plain ADPlus.VBS from the debugger package. ... debug info loaded, etc... ... InitializeCriticalSection in order to avoid memory resource exceptions ... does that avoid using the stack ?!? ...
    (microsoft.public.win32.programmer.kernel)
  • Re: tracking down error in MFC42.dll
    ... The beginning of the call stack resolves to the following: ... Run an application that uses mfc42.dll under debugger, ... The same could be done for your dll if it would be built with debug information ... If you put symbols of your dll on the target system, ...
    (microsoft.public.vc.mfc)
  • Re: "User Breakpoint" in JVM
    ... The call stack and debug ... window just show errors in jvm.dll and ntdll.dll. ... > when you start a process under debugger. ...
    (microsoft.public.vc.debugger)
  • Re: Debugging A setup project ? how to debug the Custom actions dll functions ?
    ... I too has the need to debug the methods pointed to from custom ... if there are any custom actions and if so, it makes the call to your method. ... Debugger started to begin debugging your method. ... > Now i would like to debug the code in the classlib. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: An unhandled win32 exception occured in .vshost.exe
    ... When i break into the already attached debugger this is on the call stack: ... [External Code] ... click "yes" to debug using selected debugger then new Visual Studio 2005 ...
    (microsoft.public.vsnet.debugging)