NOTABUG in glibc
The glibc malloc implementation has a number of heap consistency checks in place to ensure that memory corruption bugs in programs are caught as early as possible and the program aborted to prevent misuse of the bug. Memory corruption through buffer overruns (or underruns) are often exploit vectors waiting to be ‘used’, which is why these consistency checks and aborts are necessary.
If the heap of a program has been found to be corrupted, the program is terminated with an error that usually looks something like this:
*** glibc detected *** ./foo: double free or corruption (!prev): 0x0000000001362010 *** ======= Backtrace: ========= /lib64/libc.so.6(+0x78a96)[0x7f3df63aea96] /lib64/libc.so.6(cfree+0x6c)[0x7f3df63b2d7c] ./foo[0x400e7c] /lib64/libc.so.6(__libc_start_main+0xed)[0x7f3df635730d] ./foo[0x4008f9] ======= Memory map: ========
and when one looks at the core dump, the top of the call stack is all inside glibc:
Program terminated with signal 6, Aborted. #0 0x00007fd0273b6925 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 64 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig); (gdb) bt #0 0x00007fd0273b6925 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 #1 0x00007fd0273b8105 in abort () at abort.c:92 #2 0x00007fd0273f4837 in __libc_message (do_abort=2, fmt=0x7fd0274dcaa0 "n not possible due to RF-kill") at ../sysdeps/unix/sysv/linux/libc_fatal.c:198 #3 0x00007fd0273fa166 in malloc_printerr (action=3, str=0x7fd0274daa5e "/proc/self/maps", ptr=) at malloc.c:6332 #4 0x00007fd0273fdf9a in _int_malloc (av=0x7fd027713e80, bytes= ) at malloc.c:4673
The common mistake one may make here is to assume that it is a glibc bug because the crash is ‘caused’ by glibc. That is the equivalent of killing the whistleblower. The crash is indeed caused by glibc, but the bug is not in glibc. glibc has only caught the bug after it has happened and halted execution of the program.
And if you think glibc is overstepping its bounds by halting the
program, you could tell it to not abort by exporting the
MALLOC_CHECK_
environment variable set to either 0
(completely silent) or 1 (prints the message on stderr). Of course,
you have to be smoking something very exotic to do that instead of
finding and fixing the bug.