printf调用导致valgrind产生kill信号

今天调试系统资源使用时,原本正常执行的程序,在valgrind环境下,频繁出现被kill的情况。在log中搜索到这样一段:

vex x86->IR: unhandled instruction bytes: 0xF3 0xF 0xBC 0xD2

==2228== valgrind: Unrecognised instruction at address 0x436a4af.

==2228==    at 0x436A4AF: __printf_fp (printf_fp.c:602)

==2228==    by 0x43662F7: vfprintf (vfprintf.c:2046)

==2228==    by 0x441BB4F: __vsnprintf_chk (vsnprintf_chk.c:63)

==2228==    by 0x9C4CF90: ???

==2228== Your program just tried to execute an instruction that Valgrind

==2228== did not recognise.  There are two possible reasons for this.

==2228== 1. Your program has a bug and erroneously jumped to a non-code

==2228==    location.  If you are running Memcheck and you just saw a

==2228==    warning about a bad jump, it's probably your program's fault.

==2228== 2. The instruction is legitimate but Valgrind doesn't handle it,

==2228==    i.e. it's Valgrind's fault.  If you think this is the case or

==2228==    you are not sure, please let us know and we'll try to fix it.

==2228== Either way, Valgrind will now raise a SIGILL signal which will

==2228== probably kill your program.

==2228==

==2228== Process terminating with default action of signal 4 (SIGILL)

==2228==  Illegal opcode at address 0x436A4AF

==2228==    at 0x436A4AF: __printf_fp (printf_fp.c:602)

==2228==    by 0x43662F7: vfprintf (vfprintf.c:2046)

==2228==    by 0x441BB4F: __vsnprintf_chk (vsnprintf_chk.c:63)

==2228==    by 0x9C4CF90: ???

大意是指我的程序执行了一段valgrind不能识别的指令,迫使它不得不产生一个kill信号!?但代码中,相关部分只是一个printf语句,而且并非所有的printf语句都会导致kill,现象很奇怪。

printf是libc中的函数,以前也没遇到过类似的问题。仔细回忆了一下,前段时间更新gcc,有可能是libc被升级了,导致valgrind出现问题。重新安装了一下新版的valgrind(v3.7.0->v3.10.0),再次运行,问题不再。

你可能感兴趣的:(printf调用导致valgrind产生kill信号)