简体   繁体   中英

Valgrind shows question marks

I have compiled a program using Code::Blocks. I have turned on "produce debugging symbols" under the "Debug" target, and also turned off "strip all symbols..." But when I run the program with Valgrind I get question marks in the output:

$ 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== 
...

What is the meaning of this output, and how do I find the piece of code that is causing this error?

Update: Solution

The problem was with Code::Blocks. It is necessary to correctly configure the project build options for the whole project and not just the "Debug" target. So all flags except "-std=c++11" were removed from the "whole project" options, so nothing was overriding the "Debug" options. Also the linker ".o" files need to be deleted when the options are changed, to force Code::Blocks to rebuild the executable.

The code needs to be compiled and linked with debug info ( -g command line option) and -fno-omit-frame-pointer for valgrind to show correct stack traces.

See The stack traces given by Memcheck (or another tool) aren't helpful. How can I improve them? for more details.

I recently had this problem and was able to resolve it by using the "--keep-debuginfo=yes" option, as suggested by the FAQ on this page .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM