valgrind

ubuntu 上使用valgrind

老子叫甜甜 提交于 2019-12-25 14:06:14
  Valgrind是一个GPL的软件,用于Linux(For x86, amd64 and ppc32)程序的内存调试和代码剖析。你可以在它的环境中运行你的程序来监视内存的使用情况,比如C 语言中的malloc和free或者 C++中的new和 delete。使用Valgrind的工具包,你可以自动的检测许多内存管理和线程的bug,避免花费太多的时间在bug寻找上,使得你的程序更加稳固。   Valgrind的主要功能   Valgrind工具包包含多个工具,如Memcheck,Cachegrind,Helgrind, Callgrind,Massif。下面分别介绍个工具的作用: Memcheck 工具主要检查下面的程序错误:   1.使用未初始化的内存 (Use of uninitialised memory)   2.使用已经释放了的内存 (Reading/writing memory after it has been free’d)   3.使用超过 malloc分配的内存空间(Reading/writing off the end of malloc’d blocks)   4.对堆栈的非法访问 (Reading/writing inappropriate areas on the stack)   5.申请的空间是否有释放 (Memory leaks – where

Why is reading a struct pointer field invalid?

a 夏天 提交于 2019-12-25 08:59:00
问题 Running the program in Valgrind, it says that there is an "Invalid read of size 8" at the transition pointer of the struct. It has something to do with the calloc? It is (nil) if it is read as is. Having a struct (called trie), it is used as follows: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> const int MAX_SIZE = 20; struct _trie { int maxNode; int nextNode; int** transition; char* fin; }; typedef struct _trie * Trie; Trie createTrie (int maxNode){ Trie

How to correct segmentation fault in my C program

江枫思渺然 提交于 2019-12-25 08:47:34
问题 I am having hard-time in debugging the following program written for knapSack #include <stdio.h> #include <stdlib.h> #include "timer.h" #define MAX(x,y) ((x)>(y) ? (x) : (y)) #define table(i,j) table[(i)*(C+1)+(j)] int main(int argc, char **argv) { FILE *fp; long N, C, opt; // # of objects, capacity int *weights, *profits, *table, *solution; // weights and profits int verbose; // Temp variables long i, j, count, size, size1, ii, jj; // Time double time; // Read input file: // first line: # of

Valgrind - adb push failed to copy vgdb

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 03:54:18
问题 I'm trying to install valgrind on my android device, but when i try to execute adb push Inst / i get an error C:\VmFiles>adb push Inst / push: Inst/data/local/Inst/bin/vgdb -> /data/local/Inst/bin/vgdb failed to copy 'Inst/data/local/Inst/bin/vgdb' to '/data/local/Inst/bin/vgdb': N o such file or directory Ofc file vgdb exists in this directory C:\VmFiles>ls Inst/data/local/Inst/bin callgrind_annotate cg_diff valgrind vgdb callgrind_control cg_merge valgrind-di-server cg_annotate ms_print

Questions about compiling Python in debug mode

倾然丶 夕夏残阳落幕 提交于 2019-12-24 16:23:21
问题 I am using Ubuntu 12.04, Python 2.7.3. I am having a segmentation fault in a C extension I have co-written. It seems to come from a pointer that was not free'd properly. I then use valgrind to find memory leaks. According to that answer, I have to compile Python in debug mode to get a valgrind friendly version of Python and get rid of its irrelevant reports. How to compile Python in debug mode? Even though the answer I linked answers part of that question, it does not provide me enough

Valgrind illegal instruction AVX

夙愿已清 提交于 2019-12-24 13:14:03
问题 I receive some error when evaluating my program using valgrind. More precisely, I get errors like vex amd64->IR: unhandled instruction bytes: 0xC5 0xF8 0x28 0x0 0xC5 0xF8 0x29 0x45 ... ... Illegal instruction I isolated the problem to a very simple example #include <immintrin.h> int main() { float f __attribute__((aligned(16))); // No need to be aligned f = 2.0f; __m128 a = _mm_broadcast_ss(&f); return 0; } The program is compiled using gcc with the options -mavx. If the SSE2 instruction _mm

Compile Valgrind for armv5

≡放荡痞女 提交于 2019-12-24 07:40:44
问题 everyone. I got some problems while cross compile valgrind for armv5(arm926ej-s). I can figure out some of them, but there is one I cannot solve. I will write these problems: Valgrind don't support armv5 in configure , I instead armv7*) with armv7*|arm*) and it works well. -mcpu=cortex-a8 is not right since I have a arm926ej-s CPU. So I use this command to replace them all in Makfiles: sed -i 's/-mcpu=cortex-a8/-mcpu=arm926ej-s/g' `find . -name "Makefile*"` There comes the problem. movw and

calloc: 4 bytes in 1 blocks are definitely lost

为君一笑 提交于 2019-12-24 07:26:23
问题 The following message gets generated after running my program under valgrind: 4 bytes in 1 blocks are definitely lost in loss record 1 of 11 ==21938== at 0x4C2DD10: calloc (vg_replace_malloc.c:623) ==21938== by 0x401636: main (syntax.c:187) That's the line of code where the leak was detected: char *word = calloc(4, sizeof(char)); //syntax.c:187 I'm not understanding what's wrong with the code above. Why is valgrind generating an error? 来源: https://stackoverflow.com/questions/43967592/calloc-4

Why doesn't valgrind massif report any function names or code references?

喜夏-厌秋 提交于 2019-12-24 01:45:31
问题 I have a program that is unexpectedly using a large amount of heap (about 3GB). I ran it through valgrind memcheck which reported no leaks, claiming that all the heap memory is still reachable. So I rebuilt all my libraries with debug options, and ran the prog through valgrind massif. I am using Valgrind-3.8.1 which I just downloaded and built on my box today. The command line was: valgrind --tool=massif myprog Valgrind produced no errors or warnings. The resulting output file is reporting

How can I get valgrind to tell me the address of each non-freed block of memory?

风格不统一 提交于 2019-12-24 00:53:52
问题 Valgrind tells me function xxx allocated memory which was not freed. Fine. It's proving more difficult than usual to trace however. To this end I have created numerous: #ifdef DEBUG fprintf(stderr, "something happening:%lx\n", (unsigned long)ptr); #endif So I just need to match these ptr addresses that are displayed with the addresses of non-freed memory. How can I get valgrind to tell me the address of each non-freed block of memory? 回答1: I don't believe Memcheck's leak checker supports