[Haskell-cafe] mallocForeignPtrArray with check against buffer overflows

Henning Thielemann lemming at henning-thielemann.de
Thu Apr 26 06:50:33 UTC 2018


I like to test whether some low-level routines overwrite non-allocated 
memory area. On the Amiga there was the program Mungwall that surrounded 
memory blocks with some byte patterns at allocation and checked the 
integrity of those patterns at deallocation. This would also be possible 
in Haskell with a modified mallocForeignPtrArray. Has someone already 
implemented this idea? If yes, how could I easily switch between the 
mallocForeignPtrArray version with such debugging support and the plain 
function? It would be unfeasible to re-compile a lot of packages only for 
debugging. Ideally the test-suite of a package would use the debugging 
version of mallocForeignPtrArray and the library part would use plain 
allocation.

I thought about using valgrind but I remember this often gave many false 
positive bug reports for Haskell programs.


More information about the Haskell-Cafe mailing list