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

I can't find where my C code is having memory leaks

I'm trying to implement a "stack" type, and the professor provided the stack.h file and most of the reverse.c code , and my job was to implement stack.c and complete reverse.c. Valgrind says that some memory is leaking but I can't find the error.…
mekac
  • 13
  • 3
1
vote
2 answers

by 0x805C19A: main (in /bin/bash) --> this is the output from Valgrind

TO build the code: make BUILD = TARGET_ --> Builds the code What command to be used to compile source code with Valgrind. Any idea? Command to run valgrind for C/C++ file valgrind --tool=memcheck --leak-check=yes --show-reachable=yes…
1
vote
0 answers

Invalid read of size 8/ Syscall param execve(argv) points to unaddressable byte(s)

Invalid read of size 8/ Syscall param execve(argv) points to unaddressable byte(s) I spent the last few days lookin for the problem but I couldn't find it. the program is an attempt to create a simple shell. this is the error message that I'm…
Yeeloman
  • 11
  • 3
1
vote
1 answer

Identify segmentation fault with valgrind

I have this C++ program: I have an array of size 2 which I initialize to 0. Afterwards I am accessing an element out of bounds of the array. However, I am getting any error with valgrind. I am compiling the code as: g++ -g test.cpp -o test And…
1
vote
1 answer

Can't solve Valgrind memory issues in Rcpp code

I have posted my package on CRAN and recived Valgrind's check results revealing some memory leaks (link). Unfortunately, I can't reproduce these errors. Therefore, I have some hypothesis why these errors occur but can't test them. So I need an…
Bogdan
  • 864
  • 10
  • 18
1
vote
0 answers

Memory leak in c simple shell implementation

My code is compiling and it is working logically for my implementation, however there are some memory leaks which is not letting me pass the checker. This is just an implementation of simple shell in C. I have spent longer than i should have trying…
1
vote
2 answers

Corrupted stack root cause detection

I have a problem with corrupted stack in multithreaded application. There is a class: class A { public: /// some public methods private: some references to other objects like: ClassA& ref; ClassB& ref2; ... some fields like: std::map
memsetter
  • 23
  • 6
1
vote
1 answer

Invalid uninitialized jump or move memory error while trying to split a char32_t string into tokens manually

I am trying to split a char32_t string into tokens separated by a delimiter. I am not using any strtok or other std library function because, it is gurrented that input string and the delimiter will be mulltibyte unicode string. Here is the function…
polu_
  • 342
  • 7
  • 17
1
vote
1 answer

Why there has an Invalid read of size 4

there is a Invalid read of size 4 shows up, but i don't know how to avoid it: this is where the valgrind tells me have the invalid read Queue* recordQueue = newQueue(NULL, NULL); FILE* file = fopen(fileName, "r"); char* processName =…
Howard Cui
  • 21
  • 2
1
vote
0 answers

Why does Valgrind enter an infinite loop when encountering more than 2 illegal characters in a configuration file?

I am currently working on a project that involves creating a toy shell replica with reading from a configuration file. I using Valgrind to check for memory leaks. The configuration file contains proper various linux commands, and a few invalid…
jphotis
  • 51
  • 4
1
vote
1 answer

Valgrind running in same docker image on different hosts reports leak on one but not the other

We are using docker devcontainers for our development. The container is running Ubuntu 22.04, gcc-11.3 and valgrind-3.18.1 We run our unit tests through valgrind in order to check for leaks etc, using the following command: /usr/bin/valgrind \ …
Steve Lorimer
  • 27,059
  • 17
  • 118
  • 213
1
vote
1 answer

How to install valgrind on windows

Im facing a problem on using valgrind to check memory leaks in C. It tells me "valgrind: command not found. I'm using windows and I installed mingw. If any one can help me I'll be grateful. enter image description here
1
vote
1 answer

I ran Valgrind but the output points to generic malloc calls as the source of the leak. Why is it hiding the details with "???"?

I'm abbreviating my Valgrind output below because it repeats numerous times with the same unhelpful output. "Unhelpful" because what am I supposed to do with these obfuscated call stacks : by 0x115EA8: ??? (in /usr/bin/dash) In place of the ??? and…
pio1dcaqr
  • 25
  • 6
1
vote
1 answer

valgrind ends without printing summary

I want to use valgrind to see if my program has memory errors. I want to run the program on Alpine linux which has different standard c library (musl vs glibc). Here is and example output on "echo" command with valgrind on the Alpine linux: / #…
1
vote
2 answers

Error when coding my own implementation of realloc()

I am contacting you because I need to code the functions realloc / strlen (signed and unsigned) / memcpy. I have recoded these functions but it's doens't working and now I have valgrind errors like Conditional jump or move depends on uninitialised…
Virgil G.
  • 75
  • 6
1 2 3
99
100