[fpc-devel] MemSize argument validity

Marco van de Voort marcov at stack.nl
Wed Feb 17 14:18:07 CET 2010


In our previous episode, Felipe Monteiro de Carvalho said:
> I think it's possible for you to write your own memory manager which
> stores data about memory blocks in a table instead and is then able to
> check if the pointer is valid or not. Some operations would be slower
> in this case, but also safer.

Such stuff is routinely done in debugging memory managers.

Afaik fastmm does this on Delphi. Together with having barriers before and
after the allocation that are checked regularly to see if they are
overwritten.

One could also fill deallocated blocks with random garbage. (trashing
memmanager), afaik there is a simple one on BDN for Delphi that does this.

It lowers speed, but one can use it to find bugs/validate(*) an app, if
possible at lower speed, and then switch back to the normal one. The FPC
functionality to trash local vars (-gt) is also useful in this regard.

(*) of course such validation is never 100%



More information about the fpc-devel mailing list