#2 Members - Reputation: 1411
Posted 01 September 2012 - 08:45 AM
You could also try http://www.drmemory.org/ but it's not so easy to use.
#3 Members - Reputation: 368
Posted 01 September 2012 - 09:08 AM
The simplest option is to enable Page Heap Mode but it does require plenty of spare address space (link with /LARGEADDRESSAWARE if it's a 32-bit program to double available address space when run on 64-bit Windows).
You could also try http://www.drmemory.org/ but it's not so easy to use.
Do these work when the "out of buond" is inside the programs memory?
#4 Moderators - Reputation: 13533
Posted 01 September 2012 - 09:42 AM
For structures that you allocate with malloc/new, most games I've worked on have had a #define that you can enable, which pads every new/malloc call with a begin/end buffer, so that you can watch the buffer areas for corruption. I guess your project doesn't have an allocator with debugging features like this?
There's some good tips in this blog post, including the above mentioned Page Heap mode:
http://randomascii.w...h-more-crashes/
Page Heap puts each allocation on its own 4-KB page, with the allocated memory aligned to the end of the page. Therefore if you overrun the buffer you will touch the next page. Page Heap ensures that the next page will be unmapped memory so you get a guaranteed access violation at the exact moment that you overrun the buffer.
Edited by Hodgman, 01 September 2012 - 09:44 AM.
#5 Members - Reputation: 521
Posted 01 September 2012 - 10:03 AM
If it's dynamic then you can use std::vector, but that requires a bit code modification.
Edited by Ripiz, 01 September 2012 - 10:03 AM.
#6 Members - Reputation: 368
Posted 01 September 2012 - 10:45 AM
#7 Members - Reputation: 2042
Posted 02 September 2012 - 12:59 PM
If so, assuming you're using Visual Studio, you can set a break point that is triggered when a particular piece of memory is modified. The call stack at that breakpoint will give you the culprit.
A better way, imho, is to start adding more assertions and/or tests.






