Glibc memory compression

Is there any way to suppress the output that glibc generates when memory corruption? This is what i see

make *** glibc detected *** /home/myname/php/sapi/cli/php: free(): invalid pointer: x0045d67f *** ======= Backtrace: ========= /lib/libc.so.6(+0x6eb41)[0x380b41] <snip> ======= Memory map: ======== 00115000-00116000 r-xp 00000000 00:00 0 [vdso] 001d7000-001ee000 r-xp 00000000 ca:01 540738 /lib/libpthread-2.12.2.so 001ee000-001ef000 r--p 00016000 ca:01 540738 /lib/libpthread-2.12.2.so 001ef000-001f0000 rw-p 00017000 ca:01 540738 /lib/libpthread-2.12.2.so <snip> 

For the work that I am doing, I didn’t care that make did not succeed (return value! = 0). These messages fill the screen and this makes the rest of my output unreadable. I tried:

 make &> /dev/null { make ; } &> /dev/null x=`make 2>&1` &> /dev/null 

but none of them will catch the conclusion. If it does not write to stderr, where does this come from? I would like a solution that did not require glibc rebuild if possible.

Here is some code that will give such an error message, but note that this has nothing to do with the code I'm working on (php source code). I just want to disable this type of output from my console.

 int main() { char* ptr = (char*)malloc(sizeof("test")); char array[]= "test"; ptr = array; free(ptr); return 0; } 
+4
source share
1 answer

Yes: run your code with the environment variable MALLOC_CHECK_ (end underscore intentionally) set to 0 .

This is partially documented in the libc manual , although there seem to be more options than just the 0 , 1 or 2 that are offered there. (The value ends with passing action as an argument to malloc_printerr() in glibc malloc/malloc.c , and the default value is 3 )

The reason you cannot redirect it is because it is specially written for /dev/tty unless you set the environment variable LIBC_FATAL_STDERR_ . (I'm not sure if this is documented anywhere, but the corresponding code can be found here .)

+7
source

All Articles