valgrind

C++ program dies with std::bad_alloc, BUT valgrind reports no memory leaks

我只是一个虾纸丫 提交于 2019-12-31 01:33:35
问题 My program fails with 'std::bad_alloc' error message. The program is scalable, so I've tested on a smaller version with valgrind and there are no memory leaks. This is an application of statistical mechanics, so I am basically making hundreds of objects, changing their internal data (in this case stl vectors of doubles), and writing to a datafile. The creation of objects lies inside a loop, so when it ends the memory is free. Something like: for (cont=0;cont<MAX;cont++){ classSection seccion;

valgrind, gcc 6.2.0 and “-fsanitize=address”

空扰寡人 提交于 2019-12-30 10:50:21
问题 Recently, when compiling with '-fsanitize=address' I am getting an execution exception when running an application with valgrind namely "ASan runtime does not come first in initial library list" I am a little clueless what valgrind actually does. The command 'ldd file.exe' delivers linux-gate.so.1 => (0xb7755000) libasan.so.3 => /usr/lib/i386-linux-gnu/libasan.so.3 (0xb7199000) libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb6fdf000) libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb6fd8000)

What does possible lost means in valgrind

隐身守侯 提交于 2019-12-30 06:41:31
问题 I have a lot of possible lost entry from valgrind. What does that mean ? As I am using sqlite and it is well tested. I don't think these are correct entry. What I am doing wrong ? 16 bytes in 1 blocks are possibly lost in loss record 30 of 844 ==23027== at 0x4A05E1C: malloc (vg_replace_malloc.c:195) ==23027== by 0x6525BE: sqlite3MemMalloc (in app_mem.out) ==23027== by 0x63C579: mallocWithAlarm (in app_mem.out) ==23027== by 0x63C904: sqlite3DbMallocRaw (in app_mem.out) ==23027== by 0x6886D6:

making valgrind able to read user input when c++ needs it

邮差的信 提交于 2019-12-29 08:51:48
问题 I am trying to run my c++ program with valgrind, however I have some points in the program which require user input from stdin, but when i run with valgrind, it wont let the user input anything for the program, is there a way around this? Been searching all around but have not found the answer. 回答1: I haven't tried it, but I found this in the man pages: --input-fd=<number> [default: 0, stdin] Specify the file descriptor to use for reading input from the user. This is used whenever valgrind

making valgrind able to read user input when c++ needs it

人走茶凉 提交于 2019-12-29 08:51:30
问题 I am trying to run my c++ program with valgrind, however I have some points in the program which require user input from stdin, but when i run with valgrind, it wont let the user input anything for the program, is there a way around this? Been searching all around but have not found the answer. 回答1: I haven't tried it, but I found this in the man pages: --input-fd=<number> [default: 0, stdin] Specify the file descriptor to use for reading input from the user. This is used whenever valgrind

Can I make valgrind ignore glibc libraries?

倾然丶 夕夏残阳落幕 提交于 2019-12-29 06:45:11
问题 Is it possible to tell valgrind to ignore some set of libraries? Specifically glibc libraries.. Actual Problem: I have some code that runs fine in normal execution. No leaks etc. When I try to run it through valgrind, I get core dumps and program restarts/stops. Core usually points to glibc functions (usually fseek, mutex etc). I understand that there might be some issue with incompatible glibc / valgrind version. I tried various valgrind releases and glibc versions but no luck. Any

Linux C/C++ Memory Leak Detection Tool

北城余情 提交于 2019-12-28 13:20:41
目录 1. 内存使用情况分析 2. 内存泄漏(memory leak) 3. Valgrind使用 1. 内存使用情况分析 0x1: 系统总内存的分析 可以从proc目录下的meminfo文件了解到当前系统内存的使用情况汇总,其中 可用的物理内存 = memfree + buffers + cached 当memfree不够时,内核会通过回写机制(pdflush线程)把cached和buffered内存回写到后备存储器,从而释放相关内存供进程使用,或者通过手动方式显式释放cache内存: echo 3 > /proc/sys/vm/drop_caches $cat /proc/meminfo MemTotal: 8388608 kB MemFree: 6880760 kB Buffers: 0 kB Cached: 1490828 kB SwapCached: 0 kB Active: 1224960 kB Inactive: 282832 kB Active(anon): 17028 kB Inactive(anon): 348 kB Active(file): 1207932 kB Inactive(file): 282484 kB Unevictable: 0 kB Mlocked: 4884 kB SwapTotal: 1999864 kB SwapFree:

使用valgrind定位内存泄露

巧了我就是萌 提交于 2019-12-28 13:19:16
简单备忘一下,valgrind的用法: valgrind --tool=memcheck --leak-check=full --log-file=a.log ./a.exe 其中:   --tool指定工具;   --leak-check指定检测级别;   --log-file指定输出到文件,不给出这个字段则输出到屏幕打印。 valgrind的错误含义:(转自http://blog.csdn.net/ai2000ai/article/details/51131645) Conditional jump or move depends on uninitialised value(s) 诊断信息A 程序行为可能与策略预期不一致,请仔细核查! 诊断信息B XXXgz导致的警告,主要是因为机器字节对齐填充了没有初始值的数据导致! 对应两个警告信息,如果是调用XXX_gzip引出的警告,则输出信息B,否则信息A。 Warning: set address range perms: large range 诊断信息 此警告可忽略! 只对应一条信息。 Syscall param *(buf) points to uninitialised byte(s) 诊断信息 请确认此系统函数所使用的参数是否需要初始化! 只对应一条信息。 Invalid read of size * 诊断信息

make fails while installing Valgrind

被刻印的时光 ゝ 提交于 2019-12-28 05:57:28
问题 I'm trying to install Valgrind on a Mac with Snow Leopard but am getting an error. This is what I'm typing into Terminal. $ curl -O http://valgrind.org/downloads/valgrind-3.8.1.tar.bz2 $ md5sum valgrind-3.8.1.tar.bz2 $ tar -xjvf valgrind-3.8.1.tar.bz2 $ cd valgrind-3.8.1 $ ./configure $ make This is the error I get. Making all in coregrind make[2]: *** No rule to make target `/usr/include/mach/mach_vm.defs', needed by `m_mach/mach_vmUser.c'. Stop. make[1]: *** [all-recursive] Error 1 make: **

Valgrind not showing line numbers in spite of -g flag (on Ubuntu 11.10/VirtualBox)

拟墨画扇 提交于 2019-12-28 03:29:07
问题 I'm following 'Learn C the Hard Way', specifically the chapter on Valgrind. This chapter gives you a deliberately wrong program to show how Valgrind works. When I run the exercise under Valgrind I do not get line numbers in my stack trace, just '(below main)' for the errors. I am definitely compiling with the -g flag. My Valgrind output is as follows: djb@twin:~/projects/Learning/C$ valgrind ./ex4 ==5190== Memcheck, a memory error detector ==5190== Copyright (C) 2002-2010, and GNU GPL'd, by