如何使用valgrind或gdb在omxplayer中找到双重自由错误

时间:2013-12-17 03:01:30

标签: debugging gdb valgrind

我有一个复杂的omxplayer版本,我使用tcp通信在多台计算机上同步多个omxplayer实例。目前,当我运行主/从设置时,我的服务器(主服务器)上出现以下错误:

*** glibc detected *** /usr/bin/omxplayer.bin: double free or corruption (!prev): 0x00dc4ba0 ***

我想最终用gdb或valgrind调试它。在解决这个问题之前,我试着看看它是否至少可以用于最简单的omxplayer命令omxplayer foo.mp4。不幸的是,他们都给了我以下错误。

gdb输出:

gdb omxplayer.bin
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/omxplayer.bin...(no debugging symbols found)...done.
(gdb) run 1.mp4
Starting program: /usr/bin/omxplayer.bin 1.mp4
/usr/bin/omxplayer.bin: error while loading shared libraries: libavcodec.so.55: cannot open shared object file: No such file or directory
[Inferior 1 (process 4460) exited with code 0177]
(gdb) quit

valgrind输出:

valgrind --tool=memcheck omxplayer  1.mp4
==4497== Memcheck, a memory error detector
==4497== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==4497== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==4497== Command: /usr/bin/omxplayer /home/raspi/media/video/clips/1.mp4
==4497== 
disInstr(arm): unhandled instruction: 0xF1010200
                 cond=15(0xF) 27:20=16(0x10) 4:4=0 3:0=0(0x0)
==4497== valgrind: Unrecognised instruction at address 0x4843588.
==4497==    at 0x4843588: ??? (in /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so)
==4497== Your program just tried to execute an instruction that Valgrind
==4497== did not recognise.  There are two possible reasons for this.
==4497== 1. Your program has a bug and erroneously jumped to a non-code
==4497==    location.  If you are running Memcheck and you just saw a
==4497==    warning about a bad jump, it's probably your program's fault.
==4497== 2. The instruction is legitimate but Valgrind doesn't handle it,
==4497==    i.e. it's Valgrind's fault.  If you think this is the case or
==4497==    you are not sure, please let us know and we'll try to fix it.
==4497== Either way, Valgrind will now raise a SIGILL signal which will
==4497== probably kill your program.
==4497== 
==4497== Process terminating with default action of signal 4 (SIGILL)
==4497==  Illegal opcode at address 0x4843588
==4497==    at 0x4843588: ??? (in /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so)
==4497== 
==4497== HEAP SUMMARY:
==4497==     in use at exit: 388 bytes in 25 blocks
==4497==   total heap usage: 25 allocs, 0 frees, 388 bytes allocated
==4497== 
==4497== LEAK SUMMARY:
==4497==    definitely lost: 0 bytes in 0 blocks
==4497==    indirectly lost: 0 bytes in 0 blocks
==4497==      possibly lost: 0 bytes in 0 blocks
==4497==    still reachable: 388 bytes in 25 blocks
==4497==         suppressed: 0 bytes in 0 blocks
==4497== Rerun with --leak-check=full to see details of leaked memory
==4497== 
==4497== For counts of detected and suppressed errors, rerun with: -v
==4497== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 13 from 6)
Illegal instruction

我在这里做错了什么?

编辑:要明确,命令omxplayer foo.mp4确实有效

1 个答案:

答案 0 :(得分:3)

  

/usr/bin/omxplayer.bin:加载共享库时出错:libavcodec.so.55

此错误表示动态加载程序未能找到libavcodec.so.55(不是一个大惊喜)。

当您在LD_LIBRARY_PATH中设置.bashrc(gdb调用 new shell,并在该shell中运行您的程序)时,最常发生这种情况。

解决方案:

  • 构建omxplayer.bin,通过在其链接行添加适当的LD_LIBRARY_PATH,您首先不需要-Wl,-rpath=/path/to/dir-with-libavcodec
  • libavcodec.so.55所在的目录添加到/etc/ld.so.conf并重新运行/sbin/ldconfig
  • 使用非交互式shell时,请勿触摸LD_LIBRARY_PATH中的.bashrc
  • 在GDB中正确设置LD_LIBRARY_PATH

    (gdb) set env LD_LIBRARY_PATH /path/to/dir-with-libavcodec

  

disInstr(arm):未处理的指令:0xF1010200

这是Valgrind的一个错误。尝试构建一个较新的版本,如果仍然存在,请将其报告给Valgrind开发人员。

最后,要查找实际的双重免费,您可以尝试AddressSanitizer