LJ Archive

Listing 4. Remember to call muntrace() in the SIGSEGV handler.

#include <stdio.h>
#include <stdlib.h>
#include <mcheck.h>
#include <signal.h>

void handler(int s) {
  muntrace();
  abort();
}

int main() {
  char *ptr;

  signal(SIGSEGV, handler);
  mtrace();
  ptr = malloc(10);
  free(ptr);
  free(ptr);

}
LJ Archive