分段错误时未生成核心转储文件

发布于 2024-09-27 21:35:56 字数 230 浏览 1 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

她比我温柔 2024-10-04 21:35:56

您需要将该命令放置

ulimit -c unlimited

在您的环境设置中。

如果您使用 bash 作为 shell,则需要将上述命令放在 ~/.bashrc 中

You need to place the command

ulimit -c unlimited

in your environment settings.

If you are using bash as your shell, you need to place the above command in ~/.bashrc

你的笑 2024-10-04 21:35:56

您可能还想尝试编辑 /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 adding ulimit -c unlimited to ~/.bashrc.

The limits.conf is the "correct" place where to specify core dump details in most Linux distros.

梦里兽 2024-10-04 21:35:56

这是因为默认情况下,您的发行版将核心文件大小限制为 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.

谈场末日恋爱 2024-10-04 21:35:56

分段错误是由于路径变量的不相关值造成的。在我的系统上,用户是sidd@sidd-Lenovo-G460,添加的内容如下。

PATH=$PATH:/home/sidd/ns-allinone-2.35/bin:/home/sidd/ns-allinone-2.35/tcl8.5.10/unix:/home/sidd/ns-allinone-2.35/tk8.5.10/unix

LD_LIBRARY_PATH=/home/sidd/ns-allinone-2.35/otcl-1.14:/home/sidd/ns-allinone-2.35/lib

TCL_LIBRARY=/home/sidd/ns-allinone-2.35/tcl8.5.10/library

请参阅这篇博文(非常重要)。

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.

PATH=$PATH:/home/sidd/ns-allinone-2.35/bin:/home/sidd/ns-allinone-2.35/tcl8.5.10/unix:/home/sidd/ns-allinone-2.35/tk8.5.10/unix

LD_LIBRARY_PATH=/home/sidd/ns-allinone-2.35/otcl-1.14:/home/sidd/ns-allinone-2.35/lib

TCL_LIBRARY=/home/sidd/ns-allinone-2.35/tcl8.5.10/library

Please refer this blog post (VERY IMPORTANT).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文