出現segment錯誤 之後沒有core的排查

檢查是否打開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 支持;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章