Questions tagged [memcheck]

Memcheck is the dynamic memory error detector tool present in Valgrind framework. It mainly helps detecting dynamic memory allocation-deallocation related error. This tool can be used for C / C++ codes.

Memcheck is the dynamic memory error checker tool present in the framework. It can detect dynamic memory usage related errors in and programs. Mainly, it shows the erroneous cases for the following scenarios

  1. Accessing memory you shouldn't, e.g. overrunning and underrunning heap blocks, overrunning the top of the stack, and accessing memory after it has been freed.
  2. Using undefined values, i.e. values that have not been initialised, or that have been derived from other undefined values.
  3. Incorrect freeing of heap memory, such as double-freeing heap blocks, or mismatched use of malloc/new/new[] versus free/delete/delete[].
  4. Overlapping src and dst pointers in memcpy and related functions.
  5. Memory leaks.

While using valgrind freamework for testing a program, memcheck is the default tool to be used for checking. When memcheck finds any error in the program, it prints out the error type and possible location in the code, along with some other process related information which helps to find out the erroneous piece of code and fix it.

Any dynamic memory debugging done with memechek tool [or default valgrind tool] are to be marked with this tag.

96 questions
2
votes
1 answer

Leak Summary is missing from valgrind log file

I'm doing a little bit of memory profiling to my software and after running standard memory leak check with valgrind's following command valgrind --tool=memcheck --leak-check=full I got following summary: ==12550== LEAK SUMMARY: ==12550==…
Tharindu Kumara
  • 4,398
  • 2
  • 28
  • 46
2
votes
0 answers

ARMv5 with Valgrind: illegal instruction

thanks to other posts here, I managed to build and install Valgrind for ARM: make clean make distclean export PATH=$PATH:/usr/local/angstrom/arm/bin export CROSS_COMPILE=/usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi- export…
der_flori
  • 81
  • 5
2
votes
2 answers

VALGRIND invalid read of size 8, linked list, freeing nodes

I'm trying to identify the reason why Valgrind is complaining. If somebody could give me a hint so that I can understand why my code is generating bad behaviour I would be very grateful. I've created an array of structures. Each entry is the…
J. Bug
  • 152
  • 1
  • 10
2
votes
0 answers

valgrind failure that looks line internal valgrind error. How to proceed?

I am trying to debug a memory leak using valgrind on CentOS. However, valgrind fails. When I run this: my_binary my_arguments the program runs just fine, except for memory leaks. When I run this: valgrind --tool=memcheck --verbose…
Michael
  • 5,775
  • 2
  • 34
  • 53
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
2 answers

Valgrind error in C++ memory leak checking

I'm trying to figure out Valgrind usage so I made a simple program but it seems Valgrind gives a strange error when I do dynamic mem allocation in class. My program is: class Valgrind_testclass { Valgrind_testclass *Obj; public: …
madu
  • 5,232
  • 14
  • 56
  • 96
2
votes
1 answer

Configuring valgrind for MPICH: wrong libmpi*.so file used

When running valgrind to detect errors in an mpi application, I get the following error: libmpi.so.0: cannot open shared object file: No such file or directory I found out the following: Valgrind documentation (section 4.9.1) states that "The MPI…
mort
  • 12,988
  • 14
  • 52
  • 97
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
0 answers

MemoryCheckCommand is set in DartConfiguration.tcl but CTest doesn't see it

When I attempt to execute my CTest script it complains that "Memory checker (MemoryCheckCommand) not set, or cannot find the specified program" but DartConfiguration.tcl has been created and MemoryCheckCommand is correctly set to…
1
vote
1 answer

Show The Command Line of Valgrind Used in Eclipse CDT

I'm using valgrind for profiling/memchecking my application in Eclipse CDT (Indigo). After profiling it with memcheck in Eclipse, I found two "possibly lost"s (both from libraries that are out of my control). So I want to add them to my…
Peter Lee
  • 12,931
  • 11
  • 73
  • 100
1
vote
1 answer

Valgrind output confusing

I am having a bit of trouble understanding the Valgrind output: 1> "Invalid write of size 4" is coming up in an auto-generated adb file, return (gnat_exit_status); -- this is line 314 of b~main.adb and the gnat_exit_status is defined like…
NWS
  • 3,080
  • 1
  • 19
  • 34
1
vote
0 answers

Memcheck a C program's memory behavior under a limited heap size

I have written a piece of C code, which dynamically allocates some structures, the one after the other. When any of the allocations fails, some of the previously allocated ones have to be freed. While I am able to successfully memcheck the…
Conme
  • 31
  • 4
1
vote
1 answer

Suppress leak check in a specific forked child

Often it's not possible to free all memory when exiting from an utility forked child process. I want to suppress memory leak detection for these in a library. I don't want to burden developers using the library with --show-leak-kinds=all to have to…
textshell
  • 1,746
  • 14
  • 21
1
vote
1 answer

Valgrind: suppress memory memory leak reporting iff program crashed

Let's assume we have automated Valgrind testing setup with maximum diagnostics configured (--leak-check=yes --track-origins=yes etc.) However, on some tests the valgrinded process might crash with SIGSEGV due to some nondeterministic bug. In that…
Laurynas Biveinis
  • 10,547
  • 4
  • 53
  • 66
1
vote
1 answer

Why does valgrind produce multiple (almost) similar leak summaries?

I run valgrind version 3.12.0 from the console like this: valgrind --log-file="valgrind.log" --leak-check=yes ./application -param The log seems to be polluted while the application is running which is interesting already because I don't think that…
FrozenTarzan
  • 834
  • 10
  • 30