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

标签 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 下运行我的应用程序,我可以毫无问题地通过此代码区域...

最佳答案

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

这是一个已定义的“未定义指令”,如果它有意义的话:有许多可能的操作码是不合法的,但这个是专门保留的指令,保证引发 #UD 无效的操作码异常,即使在未来的处理器上也是如此。

有一个(我只能想到一个)隐约合理的原因可以解释为什么它可能被代码故意执行:GCC 内置的__builtin_trap() 生成x86 上的 UD2 指令,我偶尔会看到它代替 abort() 来导致 fatal error ,该错误将被调试器捕获。

关于c++ - valgrind 未处理的指令字节 : 0xF 0xB 0xFF 0x85,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6859267/

相关文章:

gcc - ARM Cortex M4 硬故障 - float

c - 使用 static const 变量时,C 中出现 "initialiser element is not constant"错误 - 有时 - 编译器设置?

c++ - 如何在 powerpc 中使用内联汇编获取 cpuid?

c++ - 何时使用 `asio_handler_invoke`?

c++ - 套接字发送/接收问题 : second client message never reaches server

c++ - AIX 库调用以获取线程信息/状态

macos - 当 `pip install virtualenv` 输出 `using cached virtualenv` 时 virtualenv 是否安装正确?

java - 在eclipse中创建maven项目出错

c++ - "new int[5]"和 "malloc(5 * sizeof(int))"之间的 C++ 有什么区别?

cocoa - Mac OS X - 系统偏好设置 Pane 无法打开