分段错误时未生成核心转储文件
我正在尝试使用 gdb 调试由我的 C 程序引起的分段错误。当我运行程序时,不会自动生成核心转储文件,并且我必须运行命令
ulimit -c unlimited
才能在下次运行时生成核心文件。
为什么核心转储文件没有自动生成,为什么我必须每次运行 ulimit 命令才能在下次运行程序时生成核心文件?
我使用的操作系统是Ubuntu 10.10。
I am trying to debug a segmentation fault caused by my C program using gdb
. A core dump file is not automatically generated when I run my program,and i have to run the command
ulimit -c unlimited
for a core file to be generated on the next run.
Why is a core dump file not generated automatically and why do I have to run the ulimit
command everytime to generate a core file on the next run of my program ?.
The operating system i use is Ubuntu 10.10.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要将该命令放置
在您的环境设置中。
如果您使用 bash 作为 shell,则需要将上述命令放在 ~/.bashrc 中
You need to place the command
in your environment settings.
If you are using bash as your shell, you need to place the above command in ~/.bashrc
您可能还想尝试编辑
/etc/security/limits.conf
文件,而不是将ulimit -c unlimited
添加到~/.bashrc
。limits.conf
是在大多数 Linux 发行版中指定核心转储详细信息的“正确”位置。You might also want to try to edit
/etc/security/limits.conf
file instead of addingulimit -c unlimited
to~/.bashrc
.The
limits.conf
is the "correct" place where to specify core dump details in most Linux distros.这是因为默认情况下,您的发行版将核心文件大小限制为 0 块。您提到的 ulimit 命令将该限制增加到无穷大。
我不了解 Ubuntu,但大多数发行版都有一个文件 /etc/limits,其中包含系统默认的资源限制。
That's because by default your distribution limits core file size to 0 blocks. The
ulimit
command you mentioned increases that limit to infinity.I don't know about Ubuntu, but most distros have a file /etc/limits with system defaults for resource limits.
分段错误是由于路径变量的不相关值造成的。在我的系统上,用户是
sidd@sidd-Lenovo-G460
,添加的内容如下。请参阅这篇博文(非常重要)。
The segmentation fault is due to irrelevant values for path variables. On my system the user is
sidd@sidd-Lenovo-G460
and the contents added are as below.Please refer this blog post (VERY IMPORTANT).