core文件被截断问题的解决办法

现象 通过gdb打开core,但看不到core的内容,信息如下:

$ gdb XXX core.XXX
GNU gdb (GDB) Red Hat Enterprise Linux ( 7.0.1-32.el5)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/XXX/XXX...done.
BFD: Warning: /home/XXX/core.XXX is truncated: expected core file size >= 747175936, found: 1236992.
 
warning: core file may not match specified executable file.
Cannot access memory at address 0x344201cc88

调查 ulimit -a的结果如下:

core file size          (blocks, -c) 1000
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 40960
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65000
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 536870912
real-time priority              (-r) 0
stack size              (kbytes, -s) 1024000
cpu time               (seconds, -t) unlimited
max user processes              (-u) 40960
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

经别人指点,说是“core file size”的值太小了。

修改core file size的方法 1 使用root用户登录,在/etc/security/limits.conf文件中,添加了“* hard core unlimited”行,添加后此文件的内容大致如下:

# /etc/security/limits.conf
#
# Each line describes a limit for a user in the form:
#
# <domain> <type> <item> <value>
#
* - msgqueue 536870912
* soft nofile 65000
* hard nofile 65000
* soft core   unlimited
* hard core   unlimited

2 修改这个文件后,退出root用户 3 退出自己的账户的全部登录的终端,然后关闭telnet工具,重新使用自己的账户登录系统,键入下面的命令,都会返回unlimited

$ ulimit -S -c
unlimited
$ ulimit -H -c
unlimited

此时core文件就不会被截断了。

参考资料 How do I enable core dumps for everybody http://www.akadia.com/services/ora_enable_core.html

原文地址: http://blog.sina.com.cn/s/blog_537f4d9b0100wi88.html

Licensed under CC BY-NC-SA 4.0
Built with Hugo
主题 StackJimmy 设计