gpt4 book ai didi

c - valgrind 无法识别树莓派中的 memcmp 指令

转载 作者:太空狗 更新时间:2023-10-29 16:38:11 26 4
gpt4 key购买 nike

我正在 Valgrind 中测试我的应用程序,我不明白为什么它会在此处对无法识别的指令抛出错误:

unsigned char *temp=SearchStartPtr;
unsigned char *NrStartPos=NULL;
unsigned char *Param=(unsigned char*)ParamName; //this is originally *char with "PAR#" inside

if(0==memcmp(temp,Param,4))
{
NrStartPos=temp;
break;
}

Valgrind 抛出这个并退出我的应用程序。

disInstr(arm): unhandled instruction: 0xF1010200
cond=15(0xF) 27:20=16(0x10) 4:4=0 3:0=0(0x0)
==7679== valgrind: Unrecognised instruction at address 0x4843588.
==7679== at 0x4843588: ??? (in /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so)
Your program just tried to execute an instruction that Valgrind
==7679== did not recognise. There are two possible reasons for this.
==7679== 1. Your program has a bug and erroneously jumped to a non-code
==7679== location. If you are running Memcheck and you just saw a
==7679== warning about a bad jump, it's probably your program's fault.
==7679== 2. The instruction is legitimate but Valgrind doesn't handle it,
==7679== i.e. it's Valgrind's fault. If you think this is the case or
==7679== you are not sure, please let us know and we'll try to fix it.
==7679== Either way, Valgrind will now raise a SIGILL signal which will
==7679== probably kill your program.
==7679==
==7679== Process terminating with default action of signal 4 (SIGILL)
==7679== Illegal opcode at address 0x4843588
==7679== at 0x4843588: ??? (in /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so)

通常代码工作正常(但我不知道它是否没有内存泄漏)。

我确定问题出在 memcmp 指令上,但我不明白哪里出了问题。

在代码的前面,我有另一条指令做同样的事情,但我可以在检查之前将其注释掉:

  memcmp(ReadPtr,ToWritePtr,sizeof(struct termios)

最佳答案

看起来这是一个 known issue在 Pi 上使用 Valgrind。

总而言之,Raspbian 中的 memcmp 库存版本使用当前 Valgrind 根本无法处理的汇编指令。不幸的是,Valgrind 显然很难支持这条特定指令,因此它不太可能发生 - bug在 Valgrind 跟踪器中提出,但已作为 WONTFIX 关闭。

关于我能看到解决此问题的唯一方法是替换您自己的 memcmp 版本,并希望它不会编译下来包含有问题的指令。

关于c - valgrind 无法识别树莓派中的 memcmp 指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20066215/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com