pleriche / FastMM4

A memory manager for Delphi and C++ Builder with powerful debugging facilities
447 stars 158 forks source link

Access violation in 64 bits when calling LogStackTrace (using JCLDebug) #53

Closed 64teubs closed 6 years ago

64teubs commented 6 years ago

Hello,

Hunting memory leaks in my application in full debug mode in 64 bits, I have an access violation when LogStackTrace is called from the DLL. Reading the code, I suspect the following line from generating this error: GetLocationInfo(Pointer(Cardinal(LAddress) - 1), LInfo); Changing it to GetLocationInfo(Pointer(LAddress - 1), LInfo); fixes the access violation, but maybe there is more to it.

PatrickvL commented 6 years ago

Obviously, casting a 64 bit memory address to a cardinal here (which is a 32 bit unsigned integer) looses the upper 32 bits, which when set to anything else but zero means the wrong address is used. It's better to cast to UIntPtr instead (or if that's not in scope, NativeUInt).

pleriche commented 6 years ago

Fixed. Thanks!