标签: valgrind

Valgrind'噪音',这是什么意思?

当我使用valgrind帮助调试我正在研究的应用程序时,我注意到大量的噪音似乎在抱怨标准库.作为测试,我做到了这一点;

echo 'int main() {return 0;}' | gcc -x c -o test -
Run Code Online (Sandbox Code Playgroud)

然后我做了这个;

valgrind ./test

==1096== Use of uninitialised value of size 8
==1096==    at 0x400A202: _dl_new_object (in /lib64/ld-2.10.1.so)
==1096==    by 0x400607F: _dl_map_object_from_fd (in /lib64/ld-2.10.1.so)
==1096==    by 0x4007A2C: _dl_map_object (in /lib64/ld-2.10.1.so)
==1096==    by 0x400199A: map_doit (in /lib64/ld-2.10.1.so)
==1096==    by 0x400D495: _dl_catch_error (in /lib64/ld-2.10.1.so)
==1096==    by 0x400189E: do_preload (in /lib64/ld-2.10.1.so)
==1096==    by 0x4003CCD: dl_main (in /lib64/ld-2.10.1.so)
==1096==    by 0x401404B: _dl_sysdep_start (in /lib64/ld-2.10.1.so)
==1096==    by 0x4001471: _dl_start (in /lib64/ld-2.10.1.so)
==1096==    by …
Run Code Online (Sandbox Code Playgroud)

c linux gcc valgrind

11
推荐指数
2
解决办法
1090
查看次数

我可以让valgrind忽略glibc库吗?

是否有可能告诉valgrind忽略一些库?特别是glibc库..

实际问题:我有一些代码在正常执行中运行良好.没有泄漏等

当我尝试通过valgrind运行它时,我得到核心转储和程序重启/停止.

核心通常指向glibc函数(通常是fseek,mutex等).我知道不兼容的glibc/valgrind版本可能存在一些问题.

我尝试了各种valgrind版本和glibc版本,但没有运气.有什么建议?

c linux valgrind glibc

11
推荐指数
2
解决办法
5757
查看次数

如何让Valgrind调试器逐步完成程序

早上好,我正在尝试使用Valgrind调试器来完成一个程序.

我的valgrind命令行是 valgrind -tool memcheck --leak-check=full --db-enable=yes ./MatchUpAcurate.exe.

我在Centos Linux 5.5版上使用valgrind-3.5.0和gdb版本7,0.1-23.el5_5.2.

当valgrind提出问题Attach to Debugger时,我输入Yes.然后,valgrind调试器返回:4428: return new tuple2<int,A>(2, i++, p->next());

当我尝试使用gdb步骤或继续命令时,valgrind说

[New Thread 0x410fd10 (LWP 6548] Cannot find user-level thread for LWP 6551: generic error.

当我尝试valgrind --single-step=yes在valgrind命令行上使用调试器选项时,valgriind说Bad option aborting.

任何valgrind用户都能告诉我如何单步执行C++源代码或继续完成程序吗?谢谢.

c++ valgrind

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

Valgrind /可以使用多个处理器吗?

有没有办法让valgrind使用多个处理器?

我正在使用valgrind的callgrind进行一些瓶颈分析,并注意到我的应用程序与在valgrind/callgrind之外运行时显着不同的资源使用行为.

当在valgrind外部运行时,它最多可以输出几个处理器,但是在valgrind中运行只使用一个处理器.这让我担心我的瓶颈会在不同的地方,从而使我的分析无效.

c++ profiling valgrind multicore

11
推荐指数
1
解决办法
3660
查看次数

gprof vs cachegrind profiles

在尝试优化代码时,我对由kcachegrdind和生成的配置文件的差异感到有些困惑gprof.具体来说,如果我使用gprof(使用-pg交换机编译等),我有这个:

Flat profile:

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls  ms/call  ms/call  name    
 89.62      3.71     3.71   204626     0.02     0.02  objR<true>::R_impl(std::vector<coords_t, std::allocator<coords_t> > const&, std::vector<unsigned long, std::allocator<unsigned long> > const&) const
  5.56      3.94     0.23 18018180     0.00     0.00  W2(coords_t const&, coords_t const&)
  3.87      4.10     0.16   200202     0.00     0.00  build_matrix(std::vector<coords_t, std::allocator<coords_t> > const&)
  0.24      4.11     0.01   400406     0.00     0.00  std::vector<double, std::allocator<double> >::vector(std::vector<double, std::allocator<double> > const&)
  0.24      4.12     0.01   100000 …
Run Code Online (Sandbox Code Playgroud)

c++ optimization profiling valgrind gprof

11
推荐指数
2
解决办法
4602
查看次数

GTK hello_world计划中的内存泄漏

所以...我正试图消除我的GTK + 3程序中的一些内存泄漏.我虽然回顾一些简单的例子来看看是否有一些我忘记的清理工具是个好主意,但文档中提供的hello_world程序也有漏洞.(下面的Valgrind输出).

这些泄漏是否可以接受?如果是这样,我应该使用其他一些应用来调试GTK程序吗?

==13717== Memcheck, a memory error detector
==13717== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==13717== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==13717== Command: ./a
==13717== 
Hello World
==13717== 
==13717== HEAP SUMMARY:
==13717==     in use at exit: 1,578,162 bytes in 11,614 blocks
==13717==   total heap usage: 45,699 allocs, 34,085 frees, 6,461,970 bytes allocated
==13717== 
==13717== LEAK SUMMARY:
==13717==    definitely lost: 2,560 bytes in 5 blocks
==13717==    indirectly lost: 6,656 …
Run Code Online (Sandbox Code Playgroud)

c gtk valgrind memory-leaks

11
推荐指数
1
解决办法
4842
查看次数

了解Linux虚拟内存:valgrind的massif输出显示有和没有--pages-as-heap的主要区别

我已经阅读了有关此参数的文档,但区别非常大!启用后,简单程序(见下文)的内存使用量约为7 GB,禁用时,报告的使用量约为160 KB.

top也显示大约7 GB,这有点证实了结果pages-as-heap=yes.

(我有一个理论,但我不相信它会解释这么大的差异,所以 - 请求一些帮助).

特别困扰我的是,大部分报告的内存使用情况都被使用std::string,而what?从未打印过(意思是 - 实际容量非常小).

我需要pages-as-heap=yes在分析我的应用程序时使用,我只是想知道如何避免"误报"


代码段:

#include <iostream>
#include <thread>
#include <vector>
#include <chrono>

void run()
{
    while (true)
    {
        std::string s;
        s += "aaaaa";
        s += "aaaaaaaaaaaaaaa";
        s += "bbbbbbbbbb";
        s += "cccccccccccccccccccccccccccccccccccccccccccccccccc";
        if (s.capacity() > 1024) std::cout << "what?" << std::endl;

        std::this_thread::sleep_for(std::chrono::seconds(1));
    }
}

int main()
{
    std::vector<std::thread> workers;
    for( unsigned i = 0; i < …
Run Code Online (Sandbox Code Playgroud)

c++ linux valgrind virtual-memory massif

11
推荐指数
2
解决办法
774
查看次数

Valgrind在为字符串赋值时报告内存泄漏

Valgrind在为字符串赋值时报告内存泄漏.

我使用以下简单代码来测试Valgrind报告的内存泄漏.

/******************************************
* FILE: t3.c
* Compiled using : g++ -g t3.c -o t3
*
* $ g++ -v
* Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/specs
* Configured with: ./configure --prefix=/usr --infodir=/share/info --mandir=/share/man
*      --enable-languages=c,c++ --with-system-zlib --program-suffix=-3.4 --enable-threads=posix
* Thread model: posix
* gcc version 3.4.6
 ******************************************/


#include <iostream>
#include <string>

using namespace std;

/**************************************************************
 **************************************************************/
int main(int argc, char *argv[])
{
   string test = "XXXXXXXXX";
   cout << "this is a test " << test << endl;
   exit(0);
}
Run Code Online (Sandbox Code Playgroud)

我使用这个命令编译:

$ …
Run Code Online (Sandbox Code Playgroud)

c++ string valgrind memory-leaks g++

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

如何更新make 3.81 linux

我是Linux新手(昨天安装的新版本),我在大学的编程课程中需要它,我被告知要安装特定程序的特定版本,但是我已经使用了apt-get install来安装他们(以前做过apt-get更新)他们的版本不正确.

我需要的程序是make 4.0和valgrind 3.10.1.

apt-get installs make 3.81和valgrind 3.10.0.SVN.

我尝试输入"apt-get install make4.0"和"apt-get install valgrind10.3.1"无济于事.我已经从互联网上下载了它们,并按照我可以理解的说明安装新版本,但它一直说我有旧的版本.(我不确定我是否可以在这里发布直接链接,如果我可以告诉我,我会发布我从哪里发布).

我做错了什么?我怎样才能解决这个问题?

我目前正在运行Linux Mint.

谢谢你提前回答.

linux valgrind makefile updates linux-mint

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

如何使用 CLion 查看 MacOS Big Sur 上的内存泄漏?

我不知道如何在使用 CLion 的 MacOS Big Sur 上使用 CLion 查看内存泄漏,我已经尝试过以下操作:

  1. Valgrind - 与 Big Sur 不兼容

  2. 来自 Clang 的 Leak Sanitizer - 据 CLion 的支持人员称,它显然与 MacOS 不兼容

  3. 在 CLion 内部,我在 CMakeLists.txt 中编写了以下命令:

       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -g")
    
    Run Code Online (Sandbox Code Playgroud)

    然后我在“首选项”菜单 ->“地址消毒剂”部分的消毒剂中写入:

       detect_stack_use_after_return=1
    
    Run Code Online (Sandbox Code Playgroud)

    根据 CLion 支持页面,他们说 Leak Sanitizer 包含在 Address sanitizer 中。

c valgrind memory-leaks clion leak-sanitizer

10
推荐指数
1
解决办法
4486
查看次数