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
1 answer

Invalid Write -- Valgrind

Hi I'm running into an munmap_chunk(): invalid pointer: error in my c program. The main problem is...I'm not even sure what all of the ways a pointer can become invalid are. I've checked all over my code for strings not being calloced with enough…
Ethan
  • 1,206
  • 3
  • 21
  • 39
2
votes
2 answers

Valgrind Error: "Invalid read of size 1" due to strstr() with C

Valgrind output: GET /cs3157/tng/index.html ==760== Invalid read of size 1 ==760== at 0x4C2E7D4: strstr (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==760== by 0x400E67: HandleTCPClient (http-server.c:101) ==760== by 0x400D42:…
Nate Brennand
  • 1,488
  • 1
  • 12
  • 20
2
votes
1 answer

It is taking forever for valgrind to find memory leaks but its takes seconds for the program to run without valgrind

I am using valgrind to find memory leaks on my program however it is taking a long time and its loading. When I run the program without valgrind it takes second, what is the problem and what should I look for in the code.
Nabmeister
  • 755
  • 1
  • 11
  • 20
2
votes
2 answers

What kind of errors is valgrind unable to detect?

I've an application which crashes with SIGSEGV. --20183-- VALGRIND INTERNAL ERROR: Valgrind received a signal 11 (SIGSEGV) - exiting --20183-- si_code=80; Faulting address: 0x0; sp: 0x409a8de60 valgrind: the 'impossible' happened: Killed by…
Karoly Horvath
  • 94,607
  • 11
  • 117
  • 176
2
votes
2 answers

Valgrind: jump or move depends on uninitialised values when allocating memory

I can't seem to figure out why I am getting this error. I run valgrind and it says that the newNode = (NodeType *)malloc(sizeof(NodeType)); is creating the error, but I can't figure out why... Basically what I'm trying to do is initialize a linked…
Andrew B
  • 71
  • 1
  • 6
2
votes
0 answers

Constructor and Destructor of a singleton object called twice

I'm facing a problem in singleton object in c++. Here is the explanation: Problem info: I have a 4 shared libraries (say libA.so, libB.so, libC.so, libD.so) and 2 executable binary files each using one another shared library( say libE.so) which…
bikram990
  • 1,085
  • 1
  • 14
  • 36
2
votes
0 answers

How to suppress openssl from valgrind

I am using openssl library. I get lot of warning from valgrind like ==923== Conditional jump or move depends on uninitialised value(s) ==923== at 0x66614C: ssl3_get_finished (in ./app.out) ==923== by 0x65FA39: ssl3_connect (in…
Vivek Goel
  • 22,942
  • 29
  • 114
  • 186
2
votes
5 answers

Too many frees when freeing graph

I have created a graph datastructure using linked lists. With this code: typedef struct vertexNode *vertexPointer; typedef struct edgeNode *edgePointer; void freeGraph(vertexPointer); /* announce function */ struct edgeNode{ vertexPointer…
Semi
  • 448
  • 1
  • 5
  • 16
2
votes
1 answer

Macports Install Error

I am installing Valgrind using macports and getting the following error: ---> Computing dependencies for valgrind ---> Building valgrind Error: org.macports.build for port valgrind returned: command execution failed Please see the log file for…
darksky
  • 20,411
  • 61
  • 165
  • 254
2
votes
1 answer

Valgrind -- possibly lost warning

I have the code below: std::string myName = "BLABLABLA"; //check if there are illegal characters for (unsigned int i = 0; i < myName.length(); i++) { const char& c = myName[i]; if (!(isalnum(c) || (c == '_') || (c == '-'))) { …
Kam
  • 5,878
  • 10
  • 53
  • 97
2
votes
1 answer

Using various tools of Valgrind during compilation

Using the different Valgrind tools for profiling and debugging individual programs is easy. I am working on a big project with lot of modules and packages. (for Router SoC). On Building the model, how do I use Valgrind for debugging during…
Akshaa
  • 91
  • 1
  • 3
2
votes
1 answer

Comparing profiles of should-be-identical runs of a C++ program to detect divergence

I have a C++ binary (GNU LilyPond) that is occasionally generating different output for the same input. valgrinding the binary is not helping to track down where this fuzz occurs, nor is reading over gprof data. What would be very useful is a…
2
votes
4 answers

How to check if a pointer variable is junk during runtime?

I use valgrind to validate my code and it reports "Conditional jump or move depends on uninitialised value(s)" in one of my functions, which takes an array of pointers as argument. Now, how do I check if an array contains junk values (might be using…
Sulla
  • 7,631
  • 9
  • 45
  • 71
2
votes
2 answers

Does massif tool work correctly with multithreaded applications?

I am developping a multithreaded application which seems to allocate huge amounts of memory during its runtiime. All the memory gets freed in the end of execution, so valgrind shows no memory leaks. I tried to use massif tool to find out what was…
Pupkov-Zadnij
  • 1,342
  • 2
  • 11
  • 21
2
votes
1 answer

Conditional jump or move depends on uninitialised value(s) on function call

I'm working on this problem for a while now and I can't figure out why it won't work. The code is just an extension of a working programm for solving a simulation problem. I've just added two string variables to the struct and also adjusted the…
Faoran
  • 23
  • 6