当我的进程双重释放时,我得到一些打印,我想知道这些信息是谁打印的?
如果我不需要,可以关闭打印吗?
// g++ hel.cpp
#include <iostream>
int main() {
int *p = new int;
delete p;
delete p;
return 1;
}
// ./a.out
*** Error in `./a.out': double free or corruption (fasttop): 0x00000000022ccc20 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x81329)[0x7fb4b3e18329]
./a.out[0x400714]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7fb4b3db9555]
./a.out[0x400629]
======= Memory map: ========
00400000-00401000 r-xp 00000000 fd:01 7210287
00600000-00601000 r--p 00000000 fd:01 7210287
00601000-00602000 rw-p 00001000 fd:01 7210287
....
Aborted
想@Barmar
函数 malloc_printerr_ 调用 _libc_message
检查_libc_message源代码或
请参阅此链接[https://sourceware.org/legacy-ml/libc-help/2014-07/msg00015.html]
答案是设置env LIBC_FATAL_STDERR_可以将输出重定向到标准错误