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),再次运行,问题不再。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值