Re: Need Help Debugging

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Sep 25, 11:25 am, "Ivan Brugiolo [MSFT]"
<ivanb...@xxxxxxxxxxxxxxxxxxxx> wrote:
Assuming you are at least on WinXp/Win2003, then AppVerifierhttp://www.microsoft.com/downloads/details.aspx?familyid=BD02C19C-125...
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 athttp://www.microsoft.com/info/cpyright.htm

"Ben" <benm5...@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.- Hide quoted text -

- Show quoted text -

Thank you for all this info!

Yea, we're XP/2003. That AppVerifier sounds interesting, but doesn't
look like it works for services ? (since it asks for a file path to
launch).

I looked at the ADPlus.vbs before... then thought might be easier to
utilize drWatson, instead of copying all the files needed for it to
work to each systems -- but if you say it makes a better dump file
might be worth to try... So I noticed i just need to copy just 5
files to make it work... not too bad... two questions:

1) when running on a remote system (not the development PC) it warns
about not having the _NT_SYMBOL_PATH defined and it'll be forced to
use 'export' symbols -- is this a big deal ? do I need to copy the PDB
file to each system i'm debugging ? I did perform a 'test' crash on a
remote system, and it debugged ok on my PC and brought me to the line
of code that caused the crash.

2) i noticed when cdb.exe is killed, it terminates the debugged
process as well - is there any way to avoid this ? i didn't find a
switch...

btw, the other thing I like about drWatson is that it seems non-
invasive.. it doesn't touch the process until it crashes... but with
cdb.exe is seems to inject itself into the process... maybe that's
what makes it better ? it definatley wouldn't be an option we can
always leave on... i guess only leave it active during the debug
phase (while drWatson could of always been there just in case).

I tried !locks while attached to my process just for kicks, but it
just returned "Scanned 549 critical sections" -- is it normal ? ...how
do u make give more details ?

.



Relevant Pages

  • Re: Need Help Debugging
    ... you should use straight and plain ADPlus.VBS from the debugger package. ... debug info loaded, etc... ... does that avoid using the stack ?!? ... which is our custom CRITICAL_SECTION class. ...
    (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: 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)
  • Re: EDatabase Error with ADO Query
    ... >wanted to avoid have to check if the table is active each time I make a call ... You could write an Onclose event for the dataset and put a debug point in it. ... Then when you get to the debug look at the call stack or try single stepping ...
    (borland.public.delphi.database.ado)