KindDragon / vld

Visual Leak Detector for Visual C++ 2008-2015
https://kinddragon.github.io/vld/
GNU Lesser General Public License v2.1
1.01k stars 316 forks source link

VLD Crashes #21

Closed rconde01 closed 7 years ago

rconde01 commented 7 years ago

I'm getting crashes every few times running vld 2.5 (although I also get crashes with vld 2.3 and 2.4). If needed I can later give more exhaustive information about my configuration, but I have a primary issue to bring up first. When my application starts vld reports several "New allocation at already allocated address" messages. When it crashes, it crashes on the getCrtBlockUse call in reportLeaks.

Based on the comment in mapBlock:

//block with this address has already been allocated. The // previously allocated block must have been freed (probably by some // mechanism unknown to VLD), or the heap wouldn't have allocated it // again. Replace the previously allocated info with the new info.

I had the following thought.

If this "unknown mechanism" is unallocating memory, then if it unallocates it and never reallocates it, the block map will stale and the contained block will no longer be valid. Then when that block is accessed you will get a crash.

I may be wrong, but my current guess is that this is the cause of my crashes. Any ideas how it could be fixed?

I'm using Visual Studio 2013, Win10, 64-bit.

KindDragon commented 7 years ago

Then when that block is accessed you will get a crash.

No, VLD shouldn't crash in that situation.

Can you give us minimal reproducible project?

rconde01 commented 7 years ago

Working on it...it's quite a large project so it's somewhat difficult.

DraconPern commented 7 years ago

So I hope I am barking up the right tree. On Windows 10, it seems like the patching of NtDll is not working correctly because the original instructions have changed. Please see https://vld.codeplex.com/discussions/657261 for my request for help. Thanks

ioannis-e commented 7 years ago

@DraconPern Please check https://github.com/ioannis-e/vld/commit/48d9fef04a3117747c594afaf3036105713323d3 We need some confirmations in order to process it in master.

DraconPern commented 7 years ago

Ah yup, I'll check it out. Though, we should probably detect the windows version and patch accordingly, otherwise, vld x64 will stop working for older OS's.

ioannis-e commented 7 years ago

Well the change should not affect older OS's but i can not test it. If you have Win7 handy and can confirm that would be great.

DraconPern commented 7 years ago

I tested @ioannis-e and it works on Windows 7 64 and Windows 10 Enterprise 1607

giumas commented 7 years ago

I have just hit the same issue. Any plan to merge the @ioannis-e fix?

KindDragon commented 7 years ago

I released a version with these changes