Valgrind显示问号

时间:2018-01-12 17:26:15

标签: c++ linux codeblocks valgrind

我使用Code :: Blocks编译了一个程序。我打开了#34;产生调试符号"在" Debug"目标,并关闭"剥离所有符号......"但是当我用Valgrind运行程序时,我在输出中得到了问号:

$ valgrind --leak-check=yes --track-origins=yes --log-file=valgrind_output.txt
~/bin/myprg

==3766== Memcheck, a memory error detector
==3766== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==3766== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==3766== Command: /home/xxxxxx/bin/myprg
==3766== Parent PID: 3209
==3766== 
==3766== Warning: client switching stacks?  SP change: 0xffefff978 --> 0xffed13da0
==3766==          to suppress, use: --max-stackframe=3062744 or greater
==3766== Invalid write of size 4
==3766==    at 0x40892B: ??? (in /home/xxxxxx/bin/myprg)
==3766==    by 0x40275C: ??? (in /home/xxxxxx/bin/myprg)
==3766==    by 0x56FB82F: (below main) (libc-start.c:291)
==3766==  Address 0xffed13ddc is on thread 1's stack
==3766== 
==3766== Invalid write of size 4
==3766==    at 0x408931: ??? (in /home/xxxxxx/bin/myprg)
==3766==    by 0x40275C: ??? (in /home/xxxxxx/bin/myprg)
==3766==    by 0x56FB82F: (below main) (libc-start.c:291)
==3766==  Address 0xffed13dd4 is on thread 1's stack
==3766== 
...

此输出的含义是什么,以及如何找到导致此错误的代码段?

更新:解决方案

问题在于Code :: Blocks。有必要为整个项目正确配置项目构建选项,而不仅仅是" Debug"目标。所以所有的标志除了" -std = c ++ 11"从整个项目中删除了#34;选项,所以没有任何东西覆盖" Debug"选项。连接器" .o"更改选项时需要删除文件,以强制Code :: Blocks重建可执行文件。

1 个答案:

答案 0 :(得分:3)

需要使用调试信息(-fno-omit-frame-pointer命令行选项)编译和链接代码,并为valgrind编译{{1}}以显示正确的堆栈跟踪。

有关详细信息,请参阅The stack traces given by Memcheck (or another tool) aren't helpful. How can I improve them?

相关问题