Normally g_malloc() and g_free() are just wrappers around
malloc() and free(), with a couple of extra features
described in the
section called Memory in the chapter called
glib: Portability and Utility. However, when
you turn on memory profiling, they are no longer
interchangeable with malloc()
and free(). So anytime you
incorrectly mix the two pairs of functions, your
program will crash.
If you're using the GNU C library, which comes with
nearly all Linux distributions, it has a special
feature which can help you debug this. Set the MALLOC_CHECK_ environment
variable to 2 before
running your program, then run the program in gdb. As soon as free() gets a pointer not created by
malloc(), abort() will be called.