Questions tagged [valgrind]

Valgrind is a dynamic analysis tool for Linux, FreeBSD, macOS, Android, and Solaris systems. It can be used for execution and data profiling as well as for finding memory leaks, race conditions, and threading errors.

Valgrind is an open source instrumentation framework for building dynamic analysis tools. It was originally developed on Linux and has since been ported to other UNIX-like systems. There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail. You can also use Valgrind to build new tools.

Valgrind works by effectively running your code in a virtual machine where extra instrumentation is available to monitor the behavior of your code in detail.

When instrumenting your code you should compile with debug symbols, like -g2 or -g3; and you should lower optimizations, like -O0 or -O1. Higher optimizations sometimes produce false positives. Also see The Valgrind Quick Start Guide.

Available GUIs frontends:

  • valkyrie
  • KDevelop lets you use Valgrind as a plugin
  • Eclipse has a GUI plugin to integrate Valgrind into its C++ Development Tools
  • Qt Creator can use memcheck and callgrind.

There are several tools for visualizing the Valgrind output

4117 questions
2
votes
3 answers

Why can't ValGrind find my symbols?

I don't know what I've done wrong, but I can't seem to fix this. According to file, test: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.16,…
MathematicalOrchid
  • 61,854
  • 19
  • 123
  • 220
2
votes
1 answer

Memory leak - g_strndup

I have this function: char *getCharVal(const char *ch, const char *att, size_t size) { CHECK_NULL(ch); CHECK_NULL(ch = strstr(ch, att)); ch += strlen(att); char *end = strchr(ch, '"'); CHECK_NULL(end); char *endTag = strstr(ch, ENDTAG); …
MaMu
  • 1,837
  • 4
  • 20
  • 36
2
votes
2 answers

Core dumped in C program

I fairly old to C programming (even though I haven't programmed in C for many years) but I am utterly stuck now. I have two source files: main.c #include #include "inputFunction.h" int main(int argc, char** argv) { char…
2
votes
0 answers

JVM not starting up on running java program in Valgrind

I am running a java program under Valgrind to check memory leaks in 32 bit Red hat Linux. While i execute the program using valgrind, JVM is not starting up throwing the below exception. Error occurred during initialization of VM Could not reserve…
srvnn
  • 75
  • 1
  • 7
2
votes
1 answer

How to use valgrind or gdb to find double free error in omxplayer

I have a complicated build of omxplayer where I use tcp communication to synchronize multiple instances of omxplayer across multiple computers. Currently, when I run the master/slave setup I get the following error on my server (master): *** glibc…
puk
  • 16,318
  • 29
  • 119
  • 199
2
votes
1 answer

Valgrind memory deallocation

I have been working on a school project and I seem to be not correctly deallocating all memory. I don't know where I missed to use free. My code looks like this #include #include #include #define MAXFILENAME 20 typedef…
scanjett
  • 25
  • 4
2
votes
1 answer

false positive "Conflicting load" with DRD?

Analyzing my C++ code with DRD (valgrind) finds a "Conflicting load", but I cannot see why. The code is as follows: int* x; int Nt = 2; x = new int[Nt]; omp_set_num_threads(Nt); #pragma omp parallel for for (int i = 0; i < Nt; i++) { x[i] =…
AstralCar
  • 55
  • 2
  • 8
2
votes
2 answers

Pros/Cons of Static and Dynamic Instrumentation

There are many static and dynamic instrumentation tools. Soot is a static instrumentation tool for Java bytecode. Pin and Valgrind are dynamic instrumentation tools for binaries. What are pros and cons for static and dynamic instrumentation tools? I…
Sangmin
  • 415
  • 1
  • 6
  • 15
2
votes
1 answer

Using perl module Test::Valgrind for any executable

How would I use Perl module Test::Valgrind for an executable written in C or C++? The documentation is not clear about it.
Pritesh Acharya
  • 1,596
  • 5
  • 15
  • 36
2
votes
1 answer

Is there a way to reuse valgrind suppression files?

On my work I need to profile some software and got some suppression files that were recorded an unknown time ago. One of these files (logging.supp) is used to suppress logging errors. I guess the logging and some other parts are changed between…
Bodo
  • 172
  • 10
2
votes
3 answers

C - Conditional jump or move depends on uninitialised value(s)

I'm getting this error from Valgrind when I try to run my program : ==23152== Conditional jump or move depends on uninitialised value(s) ==23152== at 0x4C2D8D0: strcmp (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==23152== by…
Kernael
  • 41
  • 1
  • 2
  • 6
2
votes
0 answers

Memory leaks in QtXmlPatterns classes

I'm developing a console Qt application that modifies lots of xml files. I noticed that my app starts to consume more and more memory over the time. For example it has been working for an hour and the memory consumption raised from 300 Mb to 700…
hank
  • 9,553
  • 3
  • 35
  • 50
2
votes
2 answers

Thread stack backtraces when program running under valgrind is interrupted

I have a server program, which doesn't have a very clean/graceful shutdown (not supposed to terminate in general). When tracing memory leaks, I run it under valgrind, but finally have to kill the process by a signal (^C). Generally I try to…
Kousik Nandy
  • 496
  • 2
  • 5
2
votes
2 answers

What all C operations does valgrind treat as 'malloc' and 'free'?

At work I'm writing a rather complex piece of software in C, and I frequently test it using valgrind. The program so far works perfectly with no memory leaks or array-bounds violations, and in the valgrind report, the number of 'frees' matched the…
MoJoe
  • 31
  • 2
2
votes
1 answer

"Bad permissions for mapped region at address" Valgrind error for a hash table

I'm pretty new to C. When I run the following code for a hash table under Valgrind: table *insertObject (table *h, int pref, char ch) { struct node x; int i; if (ch < 0) { ch=256-ch; } x.chr=ch; x.pref=pref; i…
user2857096
  • 33
  • 1
  • 1
  • 5