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
0
votes
0 answers

Error reported when debug MPI Fortran program using valgrind memcheck

I am trying to debug my MPI program written in Fortran by using valgrind memcheck. However, even if I debug a minimal MPI program, Memcheck always reports an error on first MPI statement, MPI_INIT(IERR) . If I comment the statements related to MPI,…
Jilong Yin
  • 278
  • 1
  • 3
  • 15
0
votes
2 answers

Cuda-memcheck and JOCL, can a java executable make use of it? (OpenCL)

I love JOCL, Java bindings for OpenCL. I would like to run Cuda-memcheck on an executable from Java, but whenever I make Java applications, they are always just JAR files that point to a Main-Class. Is there a way to create a .exe file like C++ does…
smuggledPancakes
  • 9,881
  • 20
  • 74
  • 113
0
votes
1 answer

How to free a deleted node in the middle of a list without valgrind errors?

This is a little test to help demonstrate and review the ouput of valgrind's memcheck. Can someone help me figure out how to remove AND free a node from the middle of the list? If I comment out the free(cur) and free(cur->lock) from the remove node…
Jared Sanchez
  • 67
  • 1
  • 10
0
votes
1 answer

Analyze with valgrind only some functions and subfunctions

I want to debug a "big" C code, and use valgrind, in particular the tool memcheck. The output is very long, due to the size of the program, and I only want to focus on some function and relative subfunctions of the program. Is it possible in…
Open the way
  • 26,225
  • 51
  • 142
  • 196
0
votes
0 answers

Debugging CUDA with memcheck, using the JCuda wrapper

I am working on an image segmentation program which uses JCuda. The project is a Maven project, the dependencies for JCuda however are stored in dll files and are not managed with maven. Since I got a runtime error in my Cuda kernel (*.ptx), which…
Mr M
  • 69
  • 8
0
votes
1 answer

Memcheck reports unitialised values when accessing local variables down the stack

I encountered a problem that Memcheck reports uninitialized values and I think these are perfectly legal. I managed to create a small example program that exhibits this behavior. I would like to know if Memcheck is really wrong and what can be done…
user7610
  • 25,267
  • 15
  • 124
  • 150
0
votes
1 answer

Memcheck - unknown source module for memory leak

I'm starting out in C++ and using memcheck to check my programs for memory leaks. If (when...) there are leaks, I get the Unfreed memory allocations remaining output, which the uses of new, malloc etc which haven't been freed. These are typically…
rbennett485
  • 1,907
  • 15
  • 24
0
votes
0 answers

Valgrind, invalid read, fgetc

Good evening everybody. I have written a function that is checking values that come from a stream by analyzing each character. If the character has the value of a specific sign the code should do something deeper in the program. Everything works…
J. Bug
  • 152
  • 1
  • 10
0
votes
0 answers

C++ Valgrind error Conditional jump or move depends on uninitialised value(s)

I have a problem with my C++ code as valgrind is giving me the error (Conditional jump or move depends on uninitialized value(s)) at lines highlighted below. I tried initializing "type" with an empty string, but doesn't seems to be working. Any help…
nandanator
  • 421
  • 1
  • 4
  • 5
0
votes
1 answer

Can Valgrind Reports be trusted if the tested program crashes

So I am running Valgrind memcheck on a program, but the program crashes when doing so. Probably because of some timing issues caused by Valgrind making the execution slower. However I do get somekind of report telling me I am loosing memory at…
jimmy
  • 1,981
  • 3
  • 19
  • 28
0
votes
4 answers

Invalid read of size 8, Invalid write of size 8 (Valgrind)

I've been playing around with the following code for several hours this evening and I am just scratching my head with it. I keep getting "Invalid write of size 8" and "Invalid read of size 8" when using a function to populate an array from…
Sterling
  • 3
  • 1
  • 2
0
votes
1 answer

Prevent valgrind from tracing any java child processes created with execvp

I have a C program in which I make an execvp call out to java like so: execvp(path_to_java, args); Where path_to_java="/usr/java/latest/jre/bin/java" and args contains a link to the jar I'm running. I know it is working - I just want to profile the…
2rs2ts
  • 10,662
  • 10
  • 51
  • 95
0
votes
2 answers

Memory leak that doesn't crash when OOM, or show up in massif/valgrind

I have an internal C++ application that will indefinitely grow--so much so that we've had to implement logic that actually kills it once the RSS reaches a certain peak size (2.0G) just to maintain some semblance of order. However, this has shown…
Redmumba
  • 207
  • 1
  • 9
0
votes
0 answers

Valgrind - program is crashing

I'm new to valgrind. While trying to check my small program, I'm getting this error: ==973== Process terminating with default action of signal 11 (SIGSEGV) ==973== Bad permissions for mapped region at address 0x57E ==973== at 0x57E: ??? ==973== …
MaMu
  • 1,837
  • 4
  • 20
  • 36
0
votes
1 answer

uninitialised value(s) - if_nan function

I have a code that calls the following function int if_nan(double a) { return a!=a; …