出现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 支持;

猜你喜欢

转载自blog.51cto.com/xiamachao/2409482
今日推荐