Bounds Checking for Visual Studi C++ 6.0

I have a C/C++ multithreaded application in Microsoft Visual Studio C++ 6.0
When I run the code in debug mode, at some point it segfaults ("Unhandled exception in MyApplication.exe: 0xC0000005: Access Violation")
Normally I can narrow down why by looking at the 'Context' drop down, showing me the stack trace back to the offending function and line of code.

But with this particular crash, all I get for context stack backtrace is '63732052()' and after that a bunch of NTDLL calls.
You can see a screenshot here: http://www.telparia.com/crash1.jpg
No matter how far back I go, I just see more of those NTDLL calls, it never hits my code.

Anyways, what I imagine is happening is somewhere in my code, I am over-writing data that doesn't belong to me.
For some odd reason, this isn't causing an immediate fault. Instead some time later when either my code touches that memory, bingo crash.

I've already tried commenting out recently added code, and visually looking for potential problems and have not yet found a solution.

Under linux there are awesome tools such as efence (http://freshmeat.net/projects/efence/) and valgrind (http://valgrind.org/)
These tools are capable of detecting when any code accesses code it shouldn't and breaks execution at the right code line.
I believe this is known as 'bounds checking' ?

I can't move the application to linux because it relies on several windows specific libraries, including some custom ODBC drivers only available for Windows.

So I need some sort of tool to detect these violations and determine where in my code the problem lies.

I found something called GlowCode (http://www.glowcode.com/) but it appears only to be a leak checker and a profilier.

I also found an app called BoundsChecker (http://www.compuware.com/products/devpartner/bounds.htm)
I don't know if BoundsChecker will help me with this, but the name certainly sounds correct.
I requested a trial, but have not yet heard from them. And at a price of $1,100 that will be hard to justify to management to purchase.

So what I'm asking is if there are any free apps out there that can help me in this situation.
Or maybe there's a way to extend the stack trace to include more than 10 functions?
Or some other solution that I'm not seeing?

I'll be rewarding points to the person who's advice leads me to locating and fixing my bug.
So if someone reccomends a product that finds it, or if someone suggests a modification to visual studio, or a technique to help narrow down the problem.
I'm open to everything.
SembianceAsked:
Who is Participating?
 
Jaime OlivaresSoftware ArchitectCommented:
The best tool is your brain.....
Is the unique debugging tool i have used in the last 20 years....

PS. Forgot to mention, I love MessageBox() and TRACE()
0
 
jkrCommented:
You could use 'BoundsChecker' for that. This (IMHO great) tool is quite expensive, but there's a trial version available via http://nashua.compuware.com/evaluations/
0
 
jkrCommented:
Oh, BTW, be sure to also get the symbol files for your OS and service pack from http://www.microsoft.com/whdc/devtools/debugging/symbolpkg.mspx ("Download Windows Symbol Packages") which will help you to identify which calls to NTDLL were made.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
nonubikCommented:
For your particular crash, is there any of your function on the call stack? Or just ntdll's (it's not clear from the picture)
0
 
SembianceAuthor Commented:
It's only NTDLL's as far as the trace goes back.
I'm taking jkr's advice and downloading the symbol packages now to see what part of NT DLL it comes from.

I've also applied for the trial version of BoundsChecker, but  haven't yet heard a response back yet.
0
 
nonubikCommented:
I can consider myself fortunate as I persuaded the management to buy one license :o)
0
 
SembianceAuthor Commented:
Okay, well, I tried several products.
Rational Purify
BoundsChecker
HeapAgent

Rational Purify evaluation kept giving me errors about licenses even though I installed the license.
HeapAgent didn't seem to work correctly.
And BoundsChecker evaluation failed to install the BoundsChecker menu in Visual Studio.

I took the advice a fellow worker, and I took my code, and ran it through a quick script.
The script added a function call that will add to a log file what line/thread is currently on.
On EVERY single line I had it do this (almost every line).

Anyways, this narrowed it down to a specific for loop where I was able to find the problem.

Now my question is, why couldn't Visual Studio remember the last x lines of source code it ran and show me them to me when it crashes?
Does anyone know of a visual studio addon that would do that?
0
 
jkrCommented:
>>Now my question is, why couldn't Visual Studio remember the last x lines of source code it ran

If the call stack is blown away (technically spoken: overwritten), no tool will be able to recover from that...
0
 
SembianceAuthor Commented:
Now I don't know who deserves points.
My solution, writing a line to a file for every line was suggested by a coworker, and not in this thread.
Although common sense, for a multi-threaded C++ app I viewed it as a last resort, but it was pretty cool how well it worked.

Anyways, what should I do about points?
No one response solved the problem.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.