嵌入式系统堆一致性检查
我遇到这样的崩溃:
#0 0x2c58def0 in raise () from /lib/libpthread.so.0
#1 0x2d9b8958 in abort () from /lib/libc.so.0
#2 0x2d9b7e34 in __malloc_consolidate () from /lib/libc.so.0
#3 0x2d9b6dc8 in malloc () from /lib/libc.so.0
我猜这是堆损坏问题。 uclibc 没有 mcheck/mprobe。 Valgrind 似乎不支持 MIPS,我的应用程序(多线程)依赖于硬件特定的驱动程序。有什么建议来检查堆的一致性并检测损坏吗?
I get a crash like this:
#0 0x2c58def0 in raise () from /lib/libpthread.so.0
#1 0x2d9b8958 in abort () from /lib/libc.so.0
#2 0x2d9b7e34 in __malloc_consolidate () from /lib/libc.so.0
#3 0x2d9b6dc8 in malloc () from /lib/libc.so.0
I guess it is a heap corruption issue. uclibc does not have mcheck/mprobe. Valgrind does not seem to MIPS support and my app (which is multi-threaded) depends on hw specific drivers. Any suggestions to check the consistency of the heap and to detect corruption?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会使用替代的malloc()(另请参阅这个答案)可以很容易地变成更详细。我并不是说您需要垃圾收集,但您似乎确实需要该链接提供的额外日志记录设施。
如果是堆损坏,收集器也会被它阻塞,并给你更有意义的消息。使用起来应该不会太困难,得到你需要的,然后停止使用(特别是如果你只是让它拦截
malloc()
)。它不会像 Valgrind 那样将问题归零,但至少它是一个选择:)
I would use a replacement malloc() (see also this answer) that can easily be made to be more verbose. I'm not saying you need garbage collection, but you do seem to need the additional logging facilities that the link provides.
If it is heap corruption, the collector is going to choke on it as well, and give you more meaningful messages. It should not be too difficult to use, get what you need, then stop using (especially if you just let it intercept
malloc()
).Its not going to zero in on the problem like Valgrind does, but at least its an option :)
您可以编写冒充硬件的存根驱动程序,这应该让您可以在功能更齐全的环境中构建和测试程序。
You could write stub drivers that pretend to be the hardware, which should let you build and test your program in a more full-featured environment.