檢查是否打開core
沒有打開的例子:
[root@senbo088]# ulimit -c
0
[root@senbo088]# ./test
Segmentation fault
打開之後的例子:
[root@senbo088]# ulimit -c unlimited
0
[root@senbo088]# ulimit -c
unlimited
[root@senbo088]# ./test
Segmentation fault (core dumped)
檢查core 的路徑
一種典型而又及其隱蔽的core不dump的錯誤是 修改了core dump的默認路徑,但是目錄不存在。
如下這種情況:
[root@senbo088]# ulimit -c
unlimited
[root@senbo088]# ./test
Segmentation fault
[root@senbo088]# sysctl -p
排查過程如下:
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key
error: "net.bridge.bridge-nf-call-iptables" is an unknown key
error: "net.bridge.bridge-nf-call-arptables" is an unknown key
kernel.printk = 0
kernel.printk = 0
kernel.corepattern = /var/core/core%e_%p
kernel.core_uses_pid = 0
[root@senbo088]# ls /var/core
ls: cannot access /var/core: No such file or directory
創建 /var/core目錄之後,就好了:
[root@senbo088]# mkdir -p /var/core/
[root@senbo088]# ./test
Segmentation fault (core dumped)
爲了支持core 最好打開-ggdb編譯選項
必需 -g / -ggdb 支持;