问题描述
什么会在 Linux 中的通用 x86 用户级应用程序上导致 SIGBUS(总线错误)?我在网上能找到的所有讨论都是关于内存对齐错误的,据我所知,这并不真正适用于 x86.
What can cause SIGBUS (bus error) on a generic x86 userland application in Linux? All of the discussion I've been able to find online is regarding memory alignment errors, which from what I understand doesn't really apply to x86.
(我的代码在 Geode 上运行,以防万一相关的特定于处理器的怪癖.)
(My code is running on a Geode, in case there are any relevant processor-specific quirks there.)
推荐答案
如果打开未对齐访问陷阱,您可以从未对齐访问获取 SIGBUS,但通常在 x86 上关闭.如果出现某种错误,您也可以通过访问内存映射设备来获取它.
You can get a SIGBUS from an unaligned access if you turn on the unaligned access trap, but normally that's off on an x86. You can also get it from accessing a memory mapped device if there's an error of some kind.
最好的办法是使用调试器来识别错误指令(SIGBUS 是同步的),并尝试查看它试图做什么.
Your best bet is using a debugger to identify the faulting instruction (SIGBUS is synchronous), and trying to see what it was trying to do.
这篇关于在 x86 Linux 上调试 SIGBUS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!