gor*_*vix 3 c++ linux valgrind codeblocks
我已经使用 Code::Blocks 编译了一个程序。我已经在“调试”目标下打开了“生成调试符号”,并且还关闭了“剥离所有符号...”但是当我使用 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==
...
Run Code Online (Sandbox Code Playgroud)
此输出的含义是什么?如何找到导致此错误的代码段?
更新:解决方案
问题出在 Code::Blocks 上。有必要为整个项目正确配置项目构建选项,而不仅仅是“调试”目标。因此,除了“-std=c++11”之外的所有标志都从“整个项目”选项中删除,因此没有任何内容覆盖“调试”选项。此外,当选项更改时,需要删除链接器“.o”文件,以强制 Code::Blocks 重建可执行文件。