How to register when a specific memory cell is recorded and with which function?

I have an error that happens very rarely, but my C ++ program crashes. It seems like I'm having a buffer overflow or something like that. I believe that these types of errors are the most difficult to diagnose.

My program always crashes due to the same damaged memory location. Is there any debugging tool that can detect when a particular memory location will be written and register a function that does this?

I am using Visual Leak Detector (VLD) for my memory leak and it works great. It replaces the original mallocs, which are proprietary, and records each distribution. I was wondering if there is something like that for memory?

I know something like this will break the program, but it can be very useful.

I am using Visual Studio 2008.

+4
source share
3 answers

If you are using Visual C ++, then look at data breakpoints .

+3
source

Many debuggers can monitor a specific memory location and interrupt whenever the contents of that location change. Not sure about your specific toolchain, but gdb certainly supports this.

+2
source

Valgrind is a tool that can detect such problems. It is free, open source and easy to use.

0
source

Source: https://habr.com/ru/post/1305666/


All Articles