- 安装 jemalloc
./configure --enable-prof --enable-stats --enable-debug --enable-fill --enable-prof-gcc --disable-prof-libunwind --enable-static
make & make install
- 编写如下代码:
#include<stdio.h>
int main(){
printf("exec finish\n");
}
编译代码和静态链接jemalloc:
gcc example.cpp -ljemalloc -L'/usr/local/lib' -I'/usr/local/include/' -lm -ldl -lpthread -static
export MALLOC_CONF='prof:true'
运行 bin:
./a.out
==> 它将是具有分段错误的核心。
gdb核心函数栈如下: