How to debug heap corruption problem?

I’m debugging a storport driver. There’s a heap corruption when I try to format the storage device. It’s only a check afterward. Is there any method to find out when the real heap corruption happens?

It’s also very strange to this storport driver. When I use fio to test the raw disk, It works fine. But when I use the management tool to format the disk, it reports heap corruption.

Have you tried special pool? ( https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/special-pool )

Unfortunately, Special pool can’t detect the error…
It there any other methods?

xxxxx@gmail.com wrote:

Unfortunately, Special pool can’t detect the error…
It there any other methods?

No idea how to detect the real location of the error automatically, and
haven’t tried things like “special pool”, yet.

However, doesn’t this sound like a kind of buffer overflow?

I had a similar problem with some code like this:

SOME_STRUCURE *p;

p = malloc( sizeof( p ) ); // wrong: size of the pointer only
-vs-
p = malloc( sizeof( *p ) ); // correct size of the buffer

Erroneously typed “sizeof( p )” instead of “sizeof( *p )”, so only the
size of a pointer got allocated instead of the real size of the
structure. So when another structure was copied to the allocated one
some bytes were written beyond the allocated buffer.

Eventually there’s something similar in your code. Just an idea.

Martin

Martin Burnicki

Senior Software Engineer

MEINBERG Funkuhren GmbH & Co. KG
Email: xxxxx@meinberg.de
Phone: +49 (0)5281 9309-14
Linkedin: https://www.linkedin.com/in/martinburnicki/

Lange Wand 9, 31812 Bad Pyrmont, Germany
Amtsgericht Hannover 17HRA 100322
Geschäftsführer/Managing Directors: Günter Meinberg, Werner Meinberg,
Andre Hartmann, Heiko Gerstung
Websites: https://www.meinberg.de https://www.meinbergglobal.com
Training: https://www.meinberg.academy