3

I am attempting to debug a memory leak within my application. The leaked object is somewhat difficult to identify (before destroying the heap), and there are many similar objects created. If it were to have the same address each session, it would make it considerably easier. As such, I'm trying to disable ASLR using /FIXED and /DYNAMICBASE:NO in the linker properties of my executable.

However, this doesn't seem to achieve the desired result, the address is still different each time. Additionally, even the addresses for argv in main are different each session. Are there some additional parameters I need to set, or am I somehow misunderstanding the purpose of these flags?

4

1 回答 1

4

You're looking at data addresses; ASLR is primarily for code. It determines where the EXE and DLL code segments are loaded.

You can override operator new to control memory allocations, and use VirtualAlloc with a defined base address to make allocations more deterministic (still could have multi-threaded race conditions though). Alternatively, use the MSVC default heap debugging facilities to identify a block by its sequence number instead of its address.

于 2016-10-24T07:15:18.287 回答