Linux在终端中使用valgrind调试qt程序

问题

在Linux在终端中使用valgrind调试qt程序,无法正常运行,直接core dump,报错如下

wk@ubuntu:~$ valgrind ./test-qt
==23648== Memcheck, a memory error detector
==23648== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==23648== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==23648== Command: ./test-qt
==23648== 
==23648== Conditional jump or move depends on uninitialised value(s)
==23648==    at 0x7B134B7: __wmemchr_avx2 (memchr-avx2.S:275)
==23648==    by 0x7A6E518: internal_fnwmatch (fnmatch_loop.c:168)
==23648==    by 0x7A71987: fnmatch@@GLIBC_2.2.5 (fnmatch.c:434)
==23648==    by 0x1F3905F5: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x7A63FA3: __scandir_tail (scandir-tail.c:54)
==23648==    by 0x1F39092D: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x1F38AA98: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x1F3808DC: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x1F36CEF5: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x1F3687C1: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x1F369F21: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x9676650: glXChooseFBConfig (in /usr/lib/x86_64-linux-gnu/libGLX.so.0.0.0)
==23648== 
==23648== Conditional jump or move depends on uninitialised value(s)
==23648==    at 0x7B13497: __wmemchr_avx2 (memchr-avx2.S:264)
==23648==    by 0x7A6E518: internal_fnwmatch (fnmatch_loop.c:168)
==23648==    by 0x7A71987: fnmatch@@GLIBC_2.2.5 (fnmatch.c:434)
==23648==    by 0x212F8B35: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x7A63FA3: __scandir_tail (scandir-tail.c:54)
==23648==    by 0x212F8E6D: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x2121CA98: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x1F3809B6: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x1F36CEF5: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x1F3687C1: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x1F369F21: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x9676650: glXChooseFBConfig (in /usr/lib/x86_64-linux-gnu/libGLX.so.0.0.0)
==23648== 
==23648== Conditional jump or move depends on uninitialised value(s)
==23648==    at 0x7B134B7: __wmemchr_avx2 (memchr-avx2.S:275)
==23648==    by 0x7A6E518: internal_fnwmatch (fnmatch_loop.c:168)
==23648==    by 0x7A71987: fnmatch@@GLIBC_2.2.5 (fnmatch.c:434)
==23648==    by 0x212F8B35: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x7A63FA3: __scandir_tail (scandir-tail.c:54)
==23648==    by 0x212F8E6D: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x212F4DD1: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x20D0941C: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x20D04CDE: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x2121CAA0: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x1F3809B6: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x1F36CEF5: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648== 
==23648== 
==23648== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==23648==  General Protection Fault
==23648==    at 0x2164CD79: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x216168F5: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x21616F17: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x20D027C2: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x212F4E50: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x20D04CEA: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x2121CAA0: ??? (in /usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so)
==23648==    by 0x1F3809B6: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x1F36CEF5: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x1F3687C1: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x1F369F21: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23648==    by 0x9676650: glXChooseFBConfig (in /usr/lib/x86_64-linux-gnu/libGLX.so.0.0.0)
==23648== 
==23648== HEAP SUMMARY:
==23648==     in use at exit: 10,929,103 bytes in 24,248 blocks
==23648==   total heap usage: 164,328 allocs, 140,080 frees, 29,667,864 bytes allocated
==23648== 
==23648== LEAK SUMMARY:
==23648==    definitely lost: 0 bytes in 0 blocks
==23648==    indirectly lost: 0 bytes in 0 blocks
==23648==      possibly lost: 30,699 bytes in 467 blocks
==23648==    still reachable: 10,815,740 bytes in 23,107 blocks
==23648==                       of which reachable via heuristic:
==23648==                         length64           : 4,832 bytes in 80 blocks
==23648==                         newarray           : 2,096 bytes in 51 blocks
==23648==         suppressed: 0 bytes in 0 blocks
==23648== Rerun with --leak-check=full to see details of leaked memory
==23648== 
==23648== For counts of detected and suppressed errors, rerun with: -v
==23648== Use --track-origins=yes to see where uninitialised values come from
==23648== ERROR SUMMARY: 5 errors from 3 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)

解决方法

需要先设置环境变量

export LIBGL_ALWAYS_SOFTWARE=1

设置后程序可以正常启动,但是仍然会报一个错误,原因和解决方法暂不知道

wk@ubuntu:~/fp200/out$ valgrind ./test-qt
==23694== Memcheck, a memory error detector
==23694== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==23694== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==23694== Command: ./test-qt
==23694== 
==23694== Conditional jump or move depends on uninitialised value(s)
==23694==    at 0x7B134B7: __wmemchr_avx2 (memchr-avx2.S:275)
==23694==    by 0x7A6E518: internal_fnwmatch (fnmatch_loop.c:168)
==23694==    by 0x7A71987: fnmatch@@GLIBC_2.2.5 (fnmatch.c:434)
==23694==    by 0x212F8B35: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==23694==    by 0x7A63FA3: __scandir_tail (scandir-tail.c:54)
==23694==    by 0x212F8E6D: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==23694==    by 0x2121CA98: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==23694==    by 0x1FB7B103: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23694==    by 0x1FB6DF37: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23694==    by 0x1FB697C1: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23694==    by 0x1FB6AF21: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23694==    by 0x9676650: glXChooseFBConfig (in /usr/lib/x86_64-linux-gnu/libGLX.so.0.0.0)
==23694== 
==23694== Conditional jump or move depends on uninitialised value(s)
==23694==    at 0x7B13497: __wmemchr_avx2 (memchr-avx2.S:264)
==23694==    by 0x7A6E518: internal_fnwmatch (fnmatch_loop.c:168)
==23694==    by 0x7A71987: fnmatch@@GLIBC_2.2.5 (fnmatch.c:434)
==23694==    by 0x212F8B35: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==23694==    by 0x7A63FA3: __scandir_tail (scandir-tail.c:54)
==23694==    by 0x212F8E6D: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==23694==    by 0x212F4DD1: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==23694==    by 0x20D0941C: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==23694==    by 0x20D031EA: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==23694==    by 0x2121CAA0: ??? (in /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so)
==23694==    by 0x1FB7B103: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23694==    by 0x1FB6DF37: ??? (in /usr/lib/x86_64-linux-gnu/libGLX_mesa.so.0.0.0)
==23694== 

参考

https://www.cnblogs.com/thammer/p/15793224.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值