valgrind

valgrind安装及使用方法详解

一世执手 提交于 2019-12-05 07:51:40
Valgrind manual: http://valgrind.org/docs/manual/manual.html valgrind介绍: l Valgrind查找内存泄露利器 Valgrind是一个GPL的软件,用于Linux(For x86, amd64 and ppc32)程序的内存调试和代码剖析。你可以在它的环境中运行你的程序来监视内存的使用情况,比如C 语言中的malloc和free或者 C++中的new和 delete。使用Valgrind的工具包,你可以自动的检测许多内存管理和线程的bug,避免花费太多的时间在bug寻找上,使得你的程序更加稳固。 l Valgrind的主要功能 Valgrind工具包包含多个工具,如Memcheck,Cachegrind,Helgrind, Callgrind,Massif。下面分别介绍个工具的作用: l Memcheck 工具主要检查下面的程序错误: 使用未初始化的内存 (Use of uninitialised memory) 使用已经释放了的内存 (Reading/writing memory after it has been free’d) 使用超过 malloc分配的内存空间(Reading/writing off the end of malloc’d blocks) 对堆栈的非法访问 (Reading

Valgrind: disable conditional jump (or whole library) check

六眼飞鱼酱① 提交于 2019-12-05 06:43:43
I am developing application using OpenSSL API. As it known, OpenSSL uses miriades of global variables which are taken by Valgrind as errors ("conditional jump or move..." etc). Thus the Valgrind's output gets clogged with errors from shared libraries. This is very inconvenient for debug purposes, because every time I get: More than X total errors detected. I'm not reporting any more. Final error counts will be inaccurate. Go fix your program! The questions are: Can I disable party libraries ( -lssl and -lcrypto in my case) memory checks in Valgrind? OR can I focus only on "definitly lost"

Valgrind giving errors with getline()

被刻印的时光 ゝ 提交于 2019-12-05 06:02:25
I have a function which calls getline() , which reads lines from a standard text file. These lines end in \r\n , as this is what the spec calls for as it is the "internet standard" for VCARD files. Anyway, I run this baby through Valgrind on OpenSUSE 11.3 with the latest GCC and Valgrind versions; no errors. However, for reasons of no relevance to this problem, I switched distros to Back Track 4 (Ubuntu based), and now I am getting a metric ton of Valgrind errors: ==21536== Conditional jump or move depends on uninitialised value(s) ==21536== at 0x40164A1: (within /lib/ld-2.11.1.so) ==21536==

Does valgrind memcheck support checking mmap

白昼怎懂夜的黑 提交于 2019-12-05 05:38:35
I am trying valgrind for detecting memory leak. It works well on heap leak(i.e. memory allocation from malloc or new). however, does it support check mmap leaking in linux? Thanks Chang Not directly, it's very hard to debug, take a look to valgrind.h VALGRIND_MALLOCLIKE_BLOCK should be put immediately after the point where a heap block -- that will be used by the client program -- is allocated. It's best to put it at the outermost level of the allocator if possible; for example, if you have a function my_alloc() which calls internal_alloc(), and the client request is put inside internal_alloc(

Debugging a core produced by valgrind

孤者浪人 提交于 2019-12-05 04:50:41
Valgrind produced a vgcore.NNNN file -- how do I debug the core using GDB? Do I need to use the original executable and supply the core, or is there some other way to do it? Using valgrind as the root executable doesn't seem to work, and using the executable that was being run under valgrind directly in GDB with the core seems to produce bad backtraces. This works fine for me: gdb ./a.out vgcore.21650 and that's how you are supposed to use the vgcore. If your program corrupted stack before crashing, then obviously you wouldn't get good stack traces from vgcore. You might want to expand your

Zero bytes lost in Valgrind

泪湿孤枕 提交于 2019-12-05 04:41:49
What does it mean when Valgrind reports o bytes lost, like here: ==27752== 0 bytes in 1 blocks are definitely lost in loss record 2 of 1,532 I suspect it is just an artifact from creative use of malloc , but it is good to be sure (-; EDIT: Of course the real question is whether it can be ignored or it is an effective leak that should be fixed by freeing those buffers. Employed Russian Yes, this is a real leak, and it should be fixed. When you malloc(0) , malloc may either give you NULL, or an address that is guaranteed to be different from that of any other object . Since you are likely on

Cross-compiling Valgrind for ARM

一世执手 提交于 2019-12-05 04:19:50
I need to cross-compile VALGRIND to run on Freescale i.MX278 (ARM 9) running Linux. I have the tool chain provided by Freescale itself. I have already set the PATH variable to tool chain path. I'm using following command further: $ export CROSS_COMPILE=arm-fsl-linux-gnueabi- $ export CC=${CROSS_COMPILE}gcc $ export CPP=${CROSS_COMPILE}cpp $ export CXX=${CROSS_COMPILE}g++ $ export LD=${CROSS_COMPILE}ld $ export AR=${CROSS_COMPILE}ar $ ./configure --target=arm-fsl-linux-gnueabi \ --host=armv7-fsl-linux-gnueabi \ --prefix=/opt/valgrind \ CFLAGS=-static It passes the ./configure but fails on make

Is there anyway a valgrind message “Conditional jump or move depends on uninitialized value” can be a so called 'false positive'

给你一囗甜甜゛ 提交于 2019-12-05 02:40:38
Most questions I find here provide a piece of code and get answered by someone pointing to the actual error. My question is about conditional jumps on uninitialized values in general. I can understand that a piece of memory should not necessarily be cleaned at the end of a program if one is sure this allocation is done only once and will probably be needed during the lifetime of a program. As far as I remember the GType system leaves a lot of unfreed memory when the program terminates. These unfreed blocks can be seen as 'false positives'. But can a 'conditional jump or move on uninitialized

new libstdc++ of gcc5.1 may allocate large heap memory

南楼画角 提交于 2019-12-05 02:27:22
valgrind detects "still reachable leak" in an empty program compiled with gcc5.1, g++ ./a.cpp , int main () {} valgrind says, valgrind ./a.out , ==32037== HEAP SUMMARY: ==32037== in use at exit: 72,704 bytes in 1 blocks ==32037== total heap usage: 1 allocs, 0 frees, 72,704 bytes allocated ==32037== ==32037== LEAK SUMMARY: ==32037== definitely lost: 0 bytes in 0 blocks ==32037== indirectly lost: 0 bytes in 0 blocks ==32037== possibly lost: 0 bytes in 0 blocks ==32037== still reachable: 72,704 bytes in 1 blocks ==32037== suppressed: 0 bytes in 0 blocks ==32037== Rerun with --leak-check=full to

Uninitialised value was created by a stack allocation

五迷三道 提交于 2019-12-05 01:49:21
问题 ==13890== Conditional jump or move depends on uninitialised value(s) ==13890== at 0x4E7E4F1: vfprintf (vfprintf.c:1629) ==13890== by 0x4E878D8: printf (printf.c:35) ==13890== by 0x400729: main (001.c:30) ==13890== Uninitialised value was created by a stack allocation ==13890== at 0x400617: main (001.c:11) The line being referenced: int limit = atoi(argv[1]); I am not sure how to fix it. I have tried searching on stackoverflow and google but I could not find the solution. The code (from