valgrind未处理的指令字节:0xF 0xB 0xFF 0x85

时间:2011-07-28 12:53:50

标签: c++ macos gcc x86 valgrind

我尝试在 valgrind 3.6.1 下使用 Apple GCC 3.2.1 (强制32位模式,仅限x86)编译我的程序,但是我得到了初始化阶段出现以下错误:

vex x86->IR: unhandled instruction bytes: 0xF 0xB 0xFF 0x85
==80746== valgrind: Unrecognised instruction at address 0x2a6c2a9.
==80746== Your program just tried to execute an instruction that Valgrind
==80746== did not recognise.  There are two possible reasons for this.
==80746== 1. Your program has a bug and erroneously jumped to a non-code
==80746==    location.  If you are running Memcheck and you just saw a
==80746==    warning about a bad jump, it's probably your program's fault.
==80746== 2. The instruction is legitimate but Valgrind doesn't handle it,
==80746==    i.e. it's Valgrind's fault.  If you think this is the case or
==80746==    you are not sure, please let us know and we'll try to fix it.
==80746== Either way, Valgrind will now raise a SIGILL signal which will
==80746== probably kill your program.
==80746== 
==80746== Process terminating with default action of signal 4 (SIGILL)
==80746==  Illegal opcode at address 0x2A6C2A9

你能告诉我这是什么指示,我该怎么办?如果我在 gdb 下运行我的应用程序,我会毫无问题地传递此代码区域...

2 个答案:

答案 0 :(得分:3)

字节序列0xF 0xB是操作码UD2

这是一个定义的"未定义指令",如果这是有道理的:有许多可能的操作码是不合法的,但是这一个特别保留作为一个保证引发{{{ 1}}操作码异常无效,即使在未来的处理器上也是如此。

有一个(我只能想到一个)模糊可能的原因,为什么它可能被代码故意执行:GCC内置#UD生成__builtin_trap()关于x86的指令,我偶尔会看到使用而不是UD2来导致致命错误,这将由调试器捕获。

答案 1 :(得分:0)

我不知道这是否有帮助,但这看起来是一个未定义的指令:

<击> http://ref.x86asm.net/coder32.html#x0F0B

更像是:http://ref.x86asm.net/coder32.html#xFB

看起来正在进行一些低级别的中断管理(例如,对于信号量)。但通常这只能通过内核模式下的特权线程来完成,所以我想知道为什么代码可以做到这一点。


我更不可能对哪条指令不正确,但valgrind对x86中的中断指令知之甚少是有意义的