Unix 上的分段错误 - 可能的堆栈损坏

发布于 2024-07-13 20:06:51 字数 410 浏览 7 评论 0原文

我正在查看 Unix 中运行的进程的核心。 通常我可以解决问题并深入回溯以尝试识别内存问题。 在这种情况下,我不确定如何继续。

首先,回溯只给出了 3 帧,我期望更多。 对于这些框架,提供的所有功能参数似乎完全无效。 没有我所期望的。

某些指针参数具有以下关联 - 无法访问地址处的内存

这是否表明某种完全堆栈损坏。 我使用 libumem 运行该过程,所有缓冲区都报告为干净的。

umem_status 也没有报告任何内容。

所以基本上我很困惑。 可能的原因是什么? 由于 libumem 似乎没有报告任何错误,我应该在代码中查找什么。

关于如何进一步调试有什么建议吗? 我应该考虑 mdb 中的任何额外功能吗?

谢谢。

i'm looking at a core from a process running in Unix.
Usually I can work my around and root into the backtrace to try identify a memory issue.
In this case, I'm not sure how to proceed.

Firstly the backtrace only gives 3 frames where I would expect alot more.
For those frames, all the function parameters presented appears to completely invalid.
There are not what I would expect.

Some pointer parameters have the following associated with them - Cannot access memory at address

Would this suggest some kind of complete stack corruption.
I ran the process with libumem and all the buffers were reported as being clean.

umem_status reported nothing either.

so basically I'm stumped.
What is the likely causes?
What should I look for in code since libumem appears to have reported no errors.

Any suggestions on how I can debug furhter? any extra features in mdb I should consider?

thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

眼前雾蒙蒙 2024-07-20 20:06:51

堆栈损坏听起来确实有可能。 一些可以尝试的事情:

  • 尽可能打开所有编译器警告!
  • 运行皮棉!
  • 如果可能的话,尝试构建和构建 在 OpenBSD 上测试你的程序,它内置了很多内存损坏检测功能。
  • 如果可能,请使用 ProPolice、StackGuard 等工具。
  • 如果您可以轻松地重现此问题,则值得在调试器中进行尝试。 尽可能缩小范围,然后逐步进行。

Stack corruption does sound like a possibility. Some things to try:

  • Turn on all compiler warnings that you can!
  • Run lint!
  • If possible, try building & testing your program on OpenBSD which has a lot of memory corruption detection built-in.
  • If possible, use some tools like ProPolice, StackGuard, et al.
  • If you can reproduce this problem easily, it's worth playing around in the debugger. Narrow it down as much as possible and then step through.
故乡的云 2024-07-20 20:06:51

您可以查看是否使用 ValgrindElectricFence 可能会提前损坏。

You can look into if using Valgrind or ElectricFence could break a little earlier for you.

冷弦 2024-07-20 20:06:51

libumem 不应该报告与电围栏相同的超限情况吗?

在测试环境中无法轻松重现,但在 unix/solaris 下的商业环境中会出现核心,但 libumem 显示没有什么不好,

shouldnt libumem report the same overrun as electric fence?

can't reproduce easy in test environment but in commercial env under unix/solaris the core occurs but libumem shows nothing bad,

月光色 2024-07-20 20:06:51

你的代码? 当这种情况发生在我身上时,我总是发现同样的事情:空指针。 崩溃时看起来很可怕,但原因最终很简单。

Your code? When this happens to me, I always find the same thing: A null pointer. Looks horrible when it crashes, but the cause is ultimately simple.

傲娇萝莉攻 2024-07-20 20:06:51

我确实遇到了类似的问题。 GDB 的回溯没有帮助。 Valgrind 来救我了。

通过 Valgrind 运行您的应用程序。 识别所有错误,例如无效写入。 分析这段代码,看看是否可以修复它们。

就我而言,我尝试进行无效写入(有时可能会写入 NULL),该写入不是在该实例上而是在其他地方显示其效果。

I did run into similar issue. The backtrace from GDB was not helpful. Valgrind came to my rescue.

Run your application through Valgrind. Identify all the errors like invalid writes. Analyze the piece of code and see if they can be fixed.

In my case I was attempting a invalid write(which at times might write NULL) which showed its effect not at that instance but else where.

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