One of the problems with dynamic memory allocation is that you can delete/ freeblock the memory and still have pointers pointing to it. When someone searches for one of these pointers, there is a chance that something might “work”, but leave it vulnerable to memory corruption, etc.
To help with these problems, some make delete/ platforms freewrite garbage (something like DEDEDEDE) to a freed heap cell before releasing it as a freed cell. This means that when someone tries to dereference a pointer to a freed cell, one can more or less always expect a data_abort exception, which should lead to a program crash. This will be when using the debug library. The release library does not do this due to performance reasons.
Can someone tell me if this behavior can be obtained on standard Linux platforms using glibc or how to perform some simple operation for this. I think this will help me find some errors much easier.
I would like to add that to enable or disable this behavior for different assemblies should be trivial. The closest I can think of is malloc hooks, unfortunately, it does not accept cell size as a parameter for free.
doron source
share