Here's how you could use checked pointers in the overrun example given earlier to determine the exact source of the error:
typedef CheckedPtr<int> intp_t; ... intp_t foo, p; int i; int opt; opt = 1; mallopt(MALLOC_FILLAREA, opt); foo = (int *)malloc(10*4); opt = M_HANDLE_ABORT; mallopt(MALLOC_WARN, opt); for (p = foo, i = 12; i > 0; p++, i--) *p = 89; /* a fatal error is generated here */ opt = M_HANDLE_IGNORE; mallopt(MALLOC_WARN, opt); free(foo);