bash 中的重定向内存泄漏错误消息

Redirect memory leak error message in bash

我在一个小型下午茶计时器脚本中使用 espeakmbrola

timer()
{ sleep  && espeak -v mb-en1 -a 200  "Alert, alert, alert, " &> /dev/null; }

不幸的是,mbrola 中似乎存在内存泄漏;它并没有阻止它工作。

$ espeak -v mb-en1 -a 200  "test" &> /dev/null 
*** Error in `mbrola': free(): invalid pointer: 0x09640180 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x6737a)[0xf753637a]
/lib/i386-linux-gnu/libc.so.6(+0x6dfb7)[0xf753cfb7]
/lib/i386-linux-gnu/libc.so.6(+0x6e776)[0xf753d776]
/lib/i386-linux-gnu/libc.so.6(_IO_wsetb+0x59)[0xf7530d79]
/lib/i386-linux-gnu/libc.so.6(+0x6c6fc)[0xf753b6fc]
/lib/i386-linux-gnu/libc.so.6(+0x2e742)[0xf74fd742]
/lib/i386-linux-gnu/libc.so.6(+0x2e801)[0xf74fd801]
mbrola(free+0x60)[0x8048c0c]
======= Memory map: ========
08048000-08050000 r-xp 00000000 fe:01 2883715                            /usr/bin/mbrola
08050000-08051000 rwxp 00007000 fe:01 2883715                            /usr/bin/mbrola
095ff000-09641000 rwxp 00000000 00:00 0                                  [heap]
f7300000-f7321000 rwxp 00000000 00:00 0 
f7321000-f7400000 ---p 00000000 00:00 0 
f74af000-f74cb000 r-xp 00000000 fe:01 11534736                           /lib/i386-linux-gnu/libgcc_s.so.1
f74cb000-f74cc000 r-xp 0001b000 fe:01 11534736                           /lib/i386-linux-gnu/libgcc_s.so.1
f74cc000-f74cd000 rwxp 0001c000 fe:01 11534736                           /lib/i386-linux-gnu/libgcc_s.so.1
f74cd000-f74cf000 rwxp 00000000 00:00 0 
f74cf000-f7680000 r-xp 00000000 fe:01 11534349                           /lib/i386-linux-gnu/libc-2.24.so
f7680000-f7682000 r-xp 001b0000 fe:01 11534349                           /lib/i386-linux-gnu/libc-2.24.so
f7682000-f7683000 rwxp 001b2000 fe:01 11534349                           /lib/i386-linux-gnu/libc-2.24.so
f7683000-f7686000 rwxp 00000000 00:00 0 
f7686000-f76d9000 r-xp 00000000 fe:01 11534358                           /lib/i386-linux-gnu/libm-2.24.so
f76d9000-f76da000 r-xp 00052000 fe:01 11534358                           /lib/i386-linux-gnu/libm-2.24.so
f76da000-f76db000 rwxp 00053000 fe:01 11534358                           /lib/i386-linux-gnu/libm-2.24.so
f76fd000-f7700000 rwxp 00000000 00:00 0 
f7700000-f7702000 r--p 00000000 00:00 0                                  [vvar]
f7702000-f7704000 r-xp 00000000 00:00 0                                  [vdso]
f7704000-f7726000 r-xp 00000000 fe:01 11534341                           /lib/i386-linux-gnu/ld-2.24.so
f7726000-f7727000 rwxp 00000000 00:00 0 
f7727000-f7728000 r-xp 00022000 fe:01 11534341                           /lib/i386-linux-gnu/ld-2.24.so
f7728000-f7729000 rwxp 00023000 fe:01 11534341                           /lib/i386-linux-gnu/ld-2.24.so
ffe64000-ffe85000 rwxp 00000000 00:00 0                                  [stack]
^C
*** Error in `mbrola': free(): invalid pointer: 0x081632a8 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x6737a)[0xf756737a]
/lib/i386-linux-gnu/libc.so.6(+0x6dfb7)[0xf756dfb7]
/lib/i386-linux-gnu/libc.so.6(+0x6e776)[0xf756e776]
/lib/i386-linux-gnu/libc.so.6(_IO_wsetb+0x59)[0xf7561d79]
/lib/i386-linux-gnu/libc.so.6(+0x6c6fc)[0xf756c6fc]
/lib/i386-linux-gnu/libc.so.6(+0x2e742)[0xf752e742]
/lib/i386-linux-gnu/libc.so.6(+0x2e801)[0xf752e801]
mbrola(free+0x60)[0x8048c0c]
======= Memory map: ========
08048000-08050000 r-xp 00000000 fe:01 2883715                            /usr/bin/mbrola
08050000-08051000 rwxp 00007000 fe:01 2883715                            /usr/bin/mbrola
08122000-08164000 rwxp 00000000 00:00 0                                  [heap]
f7300000-f7321000 rwxp 00000000 00:00 0 
f7321000-f7400000 ---p 00000000 00:00 0 
f74e0000-f74fc000 r-xp 00000000 fe:01 11534736                           /lib/i386-linux-gnu/libgcc_s.so.1
f74fc000-f74fd000 r-xp 0001b000 fe:01 11534736                           /lib/i386-linux-gnu/libgcc_s.so.1
f74fd000-f74fe000 rwxp 0001c000 fe:01 11534736                           /lib/i386-linux-gnu/libgcc_s.so.1
f74fe000-f7500000 rwxp 00000000 00:00 0 
f7500000-f76b1000 r-xp 00000000 fe:01 11534349                           /lib/i386-linux-gnu/libc-2.24.so
f76b1000-f76b3000 r-xp 001b0000 fe:01 11534349                           /lib/i386-linux-gnu/libc-2.24.so
f76b3000-f76b4000 rwxp 001b2000 fe:01 11534349                           /lib/i386-linux-gnu/libc-2.24.so
f76b4000-f76b7000 rwxp 00000000 00:00 0 
f76b7000-f770a000 r-xp 00000000 fe:01 11534358                           /lib/i386-linux-gnu/libm-2.24.so
f770a000-f770b000 r-xp 00052000 fe:01 11534358                           /lib/i386-linux-gnu/libm-2.24.so
f770b000-f770c000 rwxp 00053000 fe:01 11534358                           /lib/i386-linux-gnu/libm-2.24.so
f772e000-f7731000 rwxp 00000000 00:00 0 
f7731000-f7733000 r--p 00000000 00:00 0                                  [vvar]
f7733000-f7735000 r-xp 00000000 00:00 0                                  [vdso]
f7735000-f7757000 r-xp 00000000 fe:01 11534341                           /lib/i386-linux-gnu/ld-2.24.so
f7757000-f7758000 rwxp 00000000 00:00 0 
f7758000-f7759000 r-xp 00022000 fe:01 11534341                           /lib/i386-linux-gnu/ld-2.24.so
f7759000-f775a000 rwxp 00023000 fe:01 11534341                           /lib/i386-linux-gnu/ld-2.24.so
ffac0000-ffae1000 rwxp 00000000 00:00 0   

如您所见,尽管我想在 /dev/null.

中下沉 stdout & stderr,但我的终端上输出了这条丑陋的错误消息

如何正确丢弃内存泄漏信息?

尝试将环境变量 MALLOC_CHECK_ 设置为零。

How to force abort on "glibc detected *** free(): invalid pointer"