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
5 answers

Is there a way to do something to static members on process end?

I have a class that uses libxml2. It has static members which are used to hold context for a schema file and its parser. I'm using valgrind, and it's complaining that memory is not deallocated in connection with the schema context. This is…
Dave
  • 5,133
  • 21
  • 27
2
votes
1 answer

c Valgrind Invalid read of size 4 -> segmentation fault

I'm trying to implement a skip list but I'm having problems with the insert part of it. Valgrind gives me invalid read of size 4 at row 44 which is this line: while(node->next_pointers[i] != NULL && node->next_pointers[i]->value < value) And it's…
Pasha
  • 33
  • 1
  • 6
2
votes
1 answer

uninitialised value(s) valgrind

When running valgrind, I'm getting a Conditional jump or move depends on uninitialised value(s) message. I've allocated a pointer to struct array, and I think it has something to do with this array. struct nlist **hashtab; void init(void) { …
KLIM8D
  • 582
  • 1
  • 8
  • 25
2
votes
2 answers

stack Uninitialised value was created by a stack allocation

The code below unicasts a udp packet with some information. I get Syscall param socketcall.sendto(msg) points to uninitialised byte(s) in main in main.c:104 and Address 0xbec64e7b is on thread 1's stack Uninitialised value was created by a stack…
Angs
  • 1,605
  • 2
  • 23
  • 47
2
votes
2 answers

Using struct for indexed buffer object in OpenGL results in segfault

I've been using std::vector's for storing vertex attributes and everything was working just fine, rendering all kinds of different meshes. But after refactoring so that my vertex attributes are stored in a struct I can't get the simplest…
Reed G. Law
  • 3,897
  • 1
  • 41
  • 78
2
votes
1 answer

Callgrind output does not include function calls

I have a simple .c program that makes a call to a function delcared and implemented in the same file. I compile it using gcc: gcc myProgram.c -o myProgram -g Then I use valgrind with callgrind to generate the callgrind.out.* file. valgrind…
user847988
  • 984
  • 1
  • 16
  • 30
2
votes
2 answers

Valgrind memcheck programmatic enable

I don't suppose there is a way to programmatically enable/disable Valgrind memcheck the way you can with callgrind? (Start/stop instrumentation). It's painfully, unusably slow (which is okay if the code you want to test starts automatically and you…
mr grumpy
  • 1,513
  • 1
  • 10
  • 17
2
votes
0 answers

Valgrind stopped with Unable to handle kernel NULL pointer dereference at virtual address 0000000

I have an OpenCV 2.4.6 application (compiled with TBB), running in ARM cortex A9 board (Odroid X2). I get segmentation fault when running the application, so first I debug with gdb. gdb cannot finish the backtrace, giving message: Backtrace stopped:…
bonchenko
  • 567
  • 1
  • 9
  • 21
2
votes
1 answer

Disable Glib event loop in Qt - QT_NO_GLIB not taking effect

When I run the thread checking tool helgrind (valgrind toolsuite) I see a lot of errors in the glib library. I want to suppress those. A suppression file is one option. But I found: How to use helgrind to debug multithreaded Qt applications. It…
Daniel Näslund
  • 2,300
  • 3
  • 22
  • 27
2
votes
2 answers

Valgrind mark deliberate leak

I feel like this has to be a feature, but my Google-Fu has failed me. I apologize in advance if this has been asked/answered before, it feels so obvious, but I couldn't find anything. Is there a means to mark an allocation as deliberately leaking?…
Pat
  • 1,882
  • 2
  • 15
  • 22
2
votes
1 answer

callgrind profile output with backtrace?

Is it possible to get back traces with the profiling output from Callgrind? If it is, would you be able to explain how that's done? [update] It could be my terminology. What is the backtrace/callstack called and where does it reside when using…
bitcycle
  • 7,632
  • 16
  • 70
  • 121
2
votes
1 answer

G-WAN with valgrind? Alternatives?

G-WAN is a convenient way to run C code on the web out-of-the-box, but for me it does not work with valgrind. (Running valgrind ./gwan there is a error message Inconsistency detected by ld.so: rtld.c: 1292: dl_main: Assertion…
ArtemGr
  • 11,684
  • 3
  • 52
  • 85
2
votes
1 answer

valgrind conditional jump or move depends on uninitialized value

I have the code below that fixes the IP addresses to 15 digit by padding 0 as prefix. #include #include #include char *function(char *newhost){ char *IPaddr; IPaddr = (char *)calloc(16,…
Johan Elmander
  • 646
  • 2
  • 8
  • 11
2
votes
2 answers

kcachegrind for RHEL 5.1

I'm about to perform profiling to application. I have vagrind, but kcachegrind is not installed. Tryied to compile without success. Where it can be obtained from for RHEL 5.1?
dimba
  • 26,717
  • 34
  • 141
  • 196
2
votes
0 answers

OpenSSL threads and Helgrind

I am implementing a multi-threaded application which makes extensive use of OpenSSL crypto library. I have followed the guidelines in several posts here (Tutorial on Using OpenSSL with pthreads, OpenSSL and multi-threads), websites (eg libcurl…
Ginswich
  • 264
  • 3
  • 13