
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.