So when glibc crashes, it has a *glibc detected * crash message. It then prints a bunch of backtraces, like
*** glibc detected *** ./odin: free(): invalid pointer: 0xbfba4444 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(+0x6b161)[0xb75f9161]
/lib/tls/i686/cmov/libc.so.6(+0x6c9b8)[0xb75fa9b8]
/lib/tls/i686/cmov/libc.so.6(cfree+0x6d)[0xb75fda9d]
/usr/lib/libstdc++.so.6(_ZdlPv+0x1f)[0xb77da2ef]
All well and good, but other cases when things crash, I’ve been doing backtrace() and then using a system call to addr2line and printing the actual points in the function instead. But when it’s a glibc crash, it quits bypassing any signal handlers I called.
Is there a way to hook against these glibc crashes?
That is an option for memory functions, you can toggle it using
mallopt. By the sounds of it you want to setM_CHECK_ACTIONto zero to allow execution to continue, unless you want the program to exit straight away in which case see if2allows you to do what you want.This small program produces the normal glibc error: test1.c
This one ignores the error and carries on: test2.c
This one aborts on the error: test3.c