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

I am unable to find out the memcheck error when i using valgrind on the given code

I am unable to detect the memory error(memcheck error) . when i run the code i see some unexpected output came. so please describe what is happening in thes code. #include #include char *getString() { char…
0
votes
2 answers

Conditional jump or move depends on uninitialised value(s) at strcpy

Valgrind detects a problem with strcpy in the following code: #include #include #include int main () { char **array; int mallocedLen = 15; int arrLen = 10; char tempArr[20][20] = {"abc", "123",…
V. Loh
  • 27
  • 5
0
votes
1 answer

Is it possible to set a baseline memory usage in valgrind for leak detection?

Is there a way to tell valgrind from inside my code when to start and when to stop checking for memory leaks? I am using a legacy testing framework which must link with my testing program in order to run. The framework has memory leaks in it -…
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
0
votes
1 answer

Valgrind (memcheck) is not displaying the leak/error summary. Help?

I typed in >>valgrind ./myprogramname --tools-memcheck --leak-check=yes But the summary of the memory leaks and errors are not printing out when the program ends. I am running Centos 5.5 and have even upgraded to the latest version of Valgrind to…
0
votes
1 answer

QTCreator Memcheck performing analysis without letting me run the actual program?

I am attempting to use QTCreator's Memcheck tool to analyze the memory of a QT project, which is a dynamic library. It uses a QT Gui (QMainWindow) to allow the user to select a file, which is then processed, and then eventually returns to the…
Tyler Shellberg
  • 1,086
  • 11
  • 28
0
votes
1 answer

Maximum verbosity in Memcheck?

From my experimentation it looks to me like the furthest maximum meaningful verbosity in Valgrind's Memcheck is two --verbose flags1. Is that true? 1: Three or more `--verbose` flags would be allowed, but I think they make no substantial change in…
1737973
  • 159
  • 18
  • 42
0
votes
1 answer

More Memcheck context lines

At the end of the program run, "leak check full" "show leak kinds all" shows a number of leak incidents in the form of sections like this, just as an example: [...] ==12522== ==12522== x bytes in 1 blocks are still reachable in loss record y of…
1737973
  • 159
  • 18
  • 42
0
votes
1 answer

How to debug error code 77: cudaErrorIllegalAddress when cuda-memcheck finds no issues?

I've got a complex Cuda C++ application that runs fine until I build the cuda code -g -G. When built debug, it crashes with cudaErrorIllegalAddress, so I ran cuda-memcheck, but that finds no issues. I also ran valgrind and it found no issues. When…
WilliamKF
  • 41,123
  • 68
  • 193
  • 295
0
votes
1 answer

How to suppress "invalid read" warning for GOT in valgrind?

I am running valgrind memcheck as part of my unit tests. Valgrind issues an "Invalid read of size 8" for a specific test views and modifies the GOT (Global Offset Table) of the process. I would like to suppress this warning preferably for just the…
smichak
  • 4,716
  • 3
  • 35
  • 47
0
votes
0 answers

Unable to get Memory Leak Reports for a process that runs through watchdog and uses shared objects

I am running a process using valgrind that uses multiple shared objects. The valgrind command is: valgrind --track-origins=yes --tool=memcheck --leak-check=full --show-reachable=yes --log-file=/tmp/PROGNAME.out -v PROGNAME ARG1 ARG2 ARG3 ARG4 ARG5…
0
votes
1 answer

Find out memory leaks in a shared library between dlopen and dlclose

We write a shared library(say slib.so) which is dlopen'ed, used and dlclose'd in a never-ending executable. I want to check for memory leaks in the library slib.so without attaching the executable. Is there any tool in Linux to find out the memory…
Srikanth
  • 517
  • 3
  • 10
  • 29
0
votes
0 answers

Still Reachable allocated memory using valgrind

I'm getting ready for an object oriented class starting in a few weeks, but I'm having trouble with the concept of deallocating memory. RIght now I'm just allocating memory to the first node of the stack, and then trying to deallocate it. If anyone…
John
  • 33
  • 7
0
votes
0 answers

cuda racecheck error if using double in kernel

I'm new in cuda coding, recently I met a racecheck error when coding and here is the very simplified code I can repeat the error: (tested on Linux and Windows) //test.cu: __global__ void kernel(){ __shared__ double s1; __shared__ double…
F.P An
  • 9
  • 1
0
votes
1 answer

valgrind memcheck gives message "in a rw- anonymous segment"

I'm using massif to debug heap increasing issue with a binary program which is running long long time. But it report: valgrind: m_mallocfree.c:280 (mk_plain_bszB): Assertion 'bszB != 0' failed. valgrind: This is probably caused by your program…
haha
  • 49
  • 1
  • 2
0
votes
1 answer

Valgrind ARM binary not working in ARM926EJ, giving error as not found

Problem: Not able to run Valgrind binary in ARM. I cross compiled the Valgrind-3-13-0 successfully in Linux host. And I moved the binaries to my ARM target. I ran Valgrind in the arm it says not found. Steps to cross-compile During the build…
danglingpointer
  • 4,708
  • 3
  • 24
  • 42