Bounds Checking for Visual Studi C++ 6.0

Posted on 2005-04-12
Last Modified: 2013-12-03
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:
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 ( and valgrind (
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 ( but it appears only to be a leak checker and a profilier.

I also found an app called BoundsChecker (
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.
Question by:Sembiance
    LVL 55

    Accepted Solution

    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()
    LVL 86

    Assisted Solution

    You could use 'BoundsChecker' for that. This (IMHO great) tool is quite expensive, but there's a trial version available via
    LVL 86

    Assisted Solution

    Oh, BTW, be sure to also get the symbol files for your OS and service pack from ("Download Windows Symbol Packages") which will help you to identify which calls to NTDLL were made.
    LVL 16

    Expert Comment

    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)

    Author Comment

    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.
    LVL 16

    Expert Comment

    I can consider myself fortunate as I persuaded the management to buy one license :o)

    Author Comment

    Okay, well, I tried several products.
    Rational Purify

    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?
    LVL 86

    Expert Comment

    >>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...

    Author Comment

    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.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
    Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now