Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/130.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ valgrind未处理的指令字节:0xF 0xB 0xFF 0x85_C++_Macos_Gcc_X86_Valgrind - Fatal编程技术网

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

C++ valgrind未处理的指令字节:0xF 0xB 0xFF 0x85,c++,macos,gcc,x86,valgrind,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 a

我试图在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下运行我的应用程序,我会毫无问题地通过此代码区域…

我不知道这是否有帮助,但这似乎是一条未定义的指令:

http://ref.x86asm.net/coder32.html#x0F0B

更像:

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



很可能我对哪条指令不正确,但valgrind对x86中的中断指令了解不多是有道理的。字节序列
0xF 0xB
是操作码
UD2

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


有一个(我只能想到一个)似是而非的理由解释为什么它可能是由代码故意执行的:GCC内置的
\uuuuu内置的
在x86上生成一条
UD2
指令,我偶尔看到它被用来代替
中止()
导致致命错误,该错误将被调试器捕获。

您可以使用debug进行编译吗?也许它会给你更多的信息。。。。特别是解决地址
0x2a6c2a9
是仅此应用程序还是此系统上valgrind的一般问题?是的,我正在运行我的应用程序的调试构建,这是valgrind遇到问题的唯一应用程序…因此您知道您在该地址正在做什么吗。我知道在GDB中,通过执行
list*address
可以通过address获取源代码。但这并没有太大帮助,因为运行valgrind时,程序的位置将与在GDB中再次运行时不同。在valgrind命令上,通过
--db attach=yes
将调试器添加到valgrind,这将(希望)在错误发生时要求您附加,然后,您可以对给定的地址执行
list*address
,这可能是调试中断(int 3)或类似的内容吗?可能是
STI
指令(需要IO权限)?这与中断无关。这是针对操作码ud2的,这是故意的undefined@Bob嘿,是的,看起来是这样:)我没想到会弹出未定义的指令,但我想这只是其中一种罕见的情况。。。谢谢,Matthew,我会努力调查的,虽然我不知道为什么gdb没有问题…该死!我错过了一个警告“无法传递非POD类型的对象…”(尽管如此,我仍然不理解为什么gdb在非POD类型上没有问题。。。