mcheck(3) Library Functions Manual mcheck(3) mcheck, mcheck_check_all, mcheck_pedantic, mprobe - C (libc, -lc) #include int mcheck(typeof(void (enum mcheck_status mstatus)) *f); int mcheck_pedantic( typeof(void (enum mcheck_status mstatus)) *f); void mcheck_check_all(void); enum mcheck_status mprobe(void *ptr); mcheck() (hooks) malloc(3). . : , , . mcheck() malloc(3) . , , -lmcheck mcheck() ( NULL) . mcheck_pedantic() mcheck(), , . ! mcheck_check_all() . , mcheck(). If the system detects an inconsistency in the heap, the caller-supplied function pointed to by f is invoked with a single argument, mstatus, that indicates what type of inconsistency was detected. If f is NULL, a default function prints an error message on stderr and calls abort(3). mprobe() , ptr. mcheck() ( mprobe() MCHECK_DISABLED). The following list describes the values returned by mprobe() or passed as the mstatus argument when f is invoked: MCHECK_DISABLED ( mprobe()) mcheck() . . MCHECK_OK ( mprobe()) . MCHECK_HEAD , , . MCHECK_TAIL . MCHECK_FREE . mcheck() mcheck_pedantic() 0, -1. attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |mcheck(), | | MT-Unsafe race:mcheck | |mcheck_pedantic(), | | const:malloc_hooks | |mcheck_check_all(), | | | |mprobe() | | | +----------------------------+----------------------------------------------------------+--------------------------+ GNU. mcheck_pedantic() mcheck_check_all() glibc 2.2. mcheck() mprobe() glibc 2.0. -lmcheck MALLOC_CHECK_ ( mallopt(3)) . MALLOC_CHECK_ . , , mcheck() NULL . : $ ./a.out About to free About to free a second time block freed twice Aborted (core dumped) #include #include #include int main(void) { char *p; if (mcheck(NULL) != 0) { fprintf(stderr, "mcheck() failed\n"); exit(EXIT_FAILURE); } p = malloc(1000); fprintf(stderr, "About to free\n"); free(p); fprintf(stderr, "\nAbout to free a second time\n"); free(p); exit(EXIT_SUCCESS); } malloc(3), mallopt(3), mtrace(3) () aereiae , Alexey , Azamat Hackimov , Dmitriy S. Seregin , Dmitry Bolkhovskikh , ITriskTI , Max Is , Yuri Kozlov , , Kirill Rekhov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.15 5 2025 . mcheck(3)