标签: valgrind

安装valgrind时出错

我尝试在我的Mac上安装valgrind但是当我执行时./autogen.sh得到这个错误:

running: aclocal
./autogen.sh: line 6: aclocal: command not found
error: while running 'aclocal'
Run Code Online (Sandbox Code Playgroud)

有谁知道如何解决这个问题?

macos valgrind

23
推荐指数
4
解决办法
2万
查看次数

为什么valgrind说基本的SDL程序正在泄漏内存?

这是SDL计划:

#include <SDL/SDL.h>

int main(int argc, char** argv){


  SDL_Init(SDL_INIT_VIDEO);
  SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE);
  SDL_Quit();
  return 0;

}
Run Code Online (Sandbox Code Playgroud)

用命令编译:

g++ -o test test.cpp -lSDL
Run Code Online (Sandbox Code Playgroud)

这是valgrind的输出:

christian@christian-laptop:~/cpp/tetris$ valgrind --leak-check=full ./test
==3271== Memcheck, a memory error detector
==3271== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==3271== Using Valgrind-3.5.0-Debian and LibVEX; rerun with -h for copyright info
==3271== Command: ./test
==3271== 
==3271== 
==3271== HEAP SUMMARY:
==3271==     in use at exit: 91,097 bytes in 1,258 blocks
==3271==   total …
Run Code Online (Sandbox Code Playgroud)

c++ valgrind sdl

22
推荐指数
2
解决办法
9882
查看次数

读取大小为8的无效 - Valgrind + C.

Valgrind Invalid read of size 8在以下代码中报告错误.

我有一个声明的数组,

struct symbol *st[PARSER_HASH_SIZE];
Run Code Online (Sandbox Code Playgroud)

当我的程序初始化时,此数组中的所有元素都被初始化为0.

memset(&st[0], 0, sizeof(st));
Run Code Online (Sandbox Code Playgroud)

我的程序struct symbol根据哈希值创建实例并插入上面的数组.因此,此数组中的少数元素将为NULL,而其他元素将为有效值.

以下代码尝试删除分配的项目和valgrind抱怨行, sym = st[i]; sym != NULL; sym = sym->next

struct symbol *sym = NULL;

/* cleaning the symbol table entries */
for(i = 0; i < PARSER_HASH_SIZE; i++) {
    for(sym = st[i]; sym != NULL; sym = sym->next) { /* <-- Valgrind complains here */
        free(sym);
    }
}
Run Code Online (Sandbox Code Playgroud)

我试图了解这个错误的原因.

任何帮助都会很棒!

c valgrind

22
推荐指数
1
解决办法
8万
查看次数

解释callgrind数据

我的应用需要动态调用图.我用callgrind工具(valgrind套件)运行它并得到callgrind.out.xxxxx文件.现在,我想对这些数据进行图形表示.KCacheGrind对我没什么帮助,因为它绘制了图形的有限部分(绘制~50个函数而不是〜1500个轮廓,我不知道如何修复它).如何获得将绘制所有函数的图形图像?

valgrind graphviz callgrind

22
推荐指数
2
解决办法
2万
查看次数

valgrind不接受最新版本的glibc

Valgrind不喜欢glibc 2.15:

checking the GLIBC_VERSION version... unsupported version 2.15
configure: error: Valgrind requires glibc version 2.2 - 2.14
Run Code Online (Sandbox Code Playgroud)

我怎么处理这个?我是否必须降级glibc?我正在研究Ubuntu 12.04,如果这是相关的信息.

更新:

所以我试图从那里下载源代码并安装,而不是使用apt-get,因为我正在通过Learn C the Hard Way.在我遇到这个问题后,我使用apt-get来查看它是否可行.它为我安装了这个包:

libc6-dbg - Embedded GNU C Library: detached debugging symbols
Run Code Online (Sandbox Code Playgroud)

valgrind

22
推荐指数
3
解决办法
7974
查看次数

了解c ++分配的内存量

我正在尝试更好地理解在c ++中分配在堆上的内存量.我写了一个小测试程序,除了填充一些2D矢量之外什么都没做.我在linux 64bit VM上运行它并使用valgrind的massif工具来分析内存.

我正在运行此测试的环境:在Win10上的VirtualBox中运行的Linux VM.VM配置:基本内存:5248MB,4CPU,上限为100%,磁盘类型VDI(动态分配存储).

c ++内存分析测试程序:

/**
 * g++ -std=c++11 test.cpp -o test.o
 */

#include <string>
#include <vector>
#include <iostream>

using namespace std;

int main(int argc, char **arg) {
    int n = stoi(arg[1]);
    vector<vector<int> > matrix1(n);
    vector<vector<int> > matrix2(n);
    vector<vector<int> > matrix3(n);
    vector<vector<int> > matrix4(n);
    vector<vector<int> > matrix5(n);
    vector<vector<int> > matrix6(n);
    vector<vector<int> > matrix7(n);
    vector<vector<int> > matrix8(n);

    for (int i=0; i<n; ++i) {
        for (int j=0; j<n; ++j) {
            matrix1[i].push_back(j);
        }
    }

    for (int i=0; i<n; ++i) { …
Run Code Online (Sandbox Code Playgroud)

c++ memory valgrind memory-management

22
推荐指数
1
解决办法
3573
查看次数

如何撤消strip - 即将符号添加回剥离的二进制文件

我有一个剥离的二进制和符号文件.是否可以将符号添加回二进制文件并创建未提取的二进制文件.

我的用例是使用这个带w/valgrind的二进制文件.

linux gdb valgrind strip

21
推荐指数
3
解决办法
5141
查看次数

为什么pthread导致内存泄漏

每当我创建一个pthread时,valgrind就会输出内存泄漏,

例如下面的代码:

#include <stdio.h>
#include <unistd.h>
#include <pthread.h> 

void *timer1_function (void *eit){
  (void) eit;
    printf("hello world\n");
    pthread_exit(NULL);
}

int main(void){
   pthread_t timer1;
   pthread_create( &timer1, NULL, timer1_function,  NULL);  ///////line13
   int i=0;
   for(i=0;i<2;i++){usleep(1);}
   return 0;
}
Run Code Online (Sandbox Code Playgroud)

valgrind输出

==1395== HEAP SUMMARY:
==1395==     in use at exit: 136 bytes in 1 blocks
==1395==   total heap usage: 6 allocs, 5 frees, 1,134 bytes allocated
==1395== 
==1395== 136 bytes in 1 blocks are possibly lost in loss record 1 of 1
==1395==    at 0x402A629: calloc (in …
Run Code Online (Sandbox Code Playgroud)

c valgrind posix memory-leaks pthreads

21
推荐指数
2
解决办法
2万
查看次数

使用pthread_create时valgrind内存泄漏错误

我正在使用pthread库编写程序.当我用命令valgrind --leak-check = full运行我的程序时,我得到以下错误描述:

==11784==  
==11784== **HEAP SUMMARY:**  
==11784==     in use at exit: 4,952 bytes in 18 blocks  
==11784==   total heap usage: 1,059 allocs, 1,041 frees, 51,864 bytes allocated  
==11784==  
==11784== **288 bytes** in 1 blocks are possibly lost in loss record 2 of 3  
==11784==    at 0x4C2380C: calloc (vg_replace_malloc.c:467)  
==11784==    by 0x4010D2E: _dl_allocate_tls (dl-tls.c:300)  
==11784==    by 0x55DC218: **pthread_create**@@GLIBC_2.2.5 (allocatestack.c:570)  
==11784==    by 0x401BC0: initdevice(char*) (in /a/fr-01/vol/home/stud/lim/workspace  /Ex3/l)  
==11784==    by 0x406D05: main (in /a/fr-01/vol/home/stud/lim/workspace/Ex3/l)  
==11784==  
==11784== **4,608 bytes** in 16 blocks …
Run Code Online (Sandbox Code Playgroud)

c++ valgrind memory-leaks pthreads

20
推荐指数
3
解决办法
2万
查看次数

几乎所有事情都给Valgrind一个错误(警告:客户端切换堆栈?)

我以某种方式破坏了内存,因为我的程序在随机位置崩溃而没有错误.

我正在使用valgrind --leak-check=full,编译-O0 -g,并且它检测到的第一个问题是第一行int main()

cout << "reading file" << endl;
Run Code Online (Sandbox Code Playgroud)

==5089== Warning: client switching stacks?  SP change: 0x7ff0004f8 --> 0x7feb7de10
==5089==          to suppress, use: --max-stackframe=4728552 or greater
==5089== Invalid write of size 8
==5089==    at 0x41E107: main (Dgn.cpp:2833)
==5089==  Address 0x7feb7de08 is on thread 1's stack
Run Code Online (Sandbox Code Playgroud)

它继续下去

==5089== Invalid read of size 8
==5089==    at 0x5DE6E10: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.18)
==5089==    by 0x67AEDE4: (below main) (libc-start.c:260) …
Run Code Online (Sandbox Code Playgroud)

c++ valgrind memory-corruption

20
推荐指数
3
解决办法
9576
查看次数