en667
en667

Reputation: 35

Pointer Validator

I am debugging a large project in C++. There are a few dereferenced pointers causing random crashes. Could you suggest me please best free tool for pointer validation? (Identification of use of invalid pointers)

(Otherwise it will took me ages to go through it manually)

Also I have used Memory Valuator program to get rid of the most memory leaks but it isn't very helpful with pointers being used after being invalidated. Platform is Windows.

UPDATE:

Before I post I have researched also other posts. And yes, it wasn’t helpful. So I would like to share my research.

One of the conditions was a FREE tool and I haven’t found any usable, and yes I have tested a dozen of them. Most of the suggested tools are designed for Leaked memory (which is not what I am looking for.) Most of pro tools like IBM’s purify do have a free or trial version but all of them are a waste of time (They only reports number of problem but nothing specific).
Other tools like Microsoft Application Verifier are pretty useful for memory or compatibility issues but it wasn’t able to identifying my problems.

Now I am testing commercial tools:

Memory Validator – perfect for mem leaks but feature “Detect deleted ‘this’ pointer” causes my application crash. (and I have spent ages with settings / config. )

Bug Validator – Much better. It identified some of the problems. However, it isn’t helpful very often. The whole Stack Trace is in crt/src/XString or Mutex initialization or inside some Critical Sections inside C++ libs. (That's it so far. I hope this info would be helpful.)

Upvotes: 2

Views: 258

Answers (3)

Chubsdad
Chubsdad

Reputation: 25507

Assuming VS2010, Run it under the debugger with the following setting:

Debug->Exceptions->Win32 Exceptions->"c0000005 Access Violation" (set the checkbox)

This would help you to get a first chance exception for pointer dereference issues such as the one in the code below

int main(){
    int buf[2];
    int *p = buf;

    p += 100;
    *p = 2;
}

It really helps as a first level technique! More advanced techniques would require WinDBG.

Upvotes: 0

Reinderien
Reinderien

Reputation: 15233

Read Is there a good Valgrind substitute for Windows? , since there's a good chance you're using Windows.

Upvotes: 3

fschmitt
fschmitt

Reputation: 3568

For Unix, I recommend valgrind.

Upvotes: 8

Related Questions