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

Are memcheck errors ever acceptable?

The valgrind quickstart page mentions: Try to make your program so clean that Memcheck reports no errors. Once you achieve this state, it is much easier to see when changes to the program cause Memcheck to report new errors. Experience from several…
Samuele B.
  • 481
  • 1
  • 6
  • 29
4
votes
2 answers

Make valgrind fail fast on a uninitalized value

Valgrind memcheck uses a bunch of heuristics to avoid false positives on "harmless" uses uninitialized values, since such uses are common both in correct and incorrect-but-otherwise functioning code. In particular, it doesn't barf until you actually…
BeeOnRope
  • 60,350
  • 16
  • 207
  • 386
4
votes
1 answer

Valgrind 8 bytes inside a block of 16 free'd

I'm writing code for a lab in class, which is an exercise in OOD design using a circular linked list. This just means that a few key functions that are used aren't accessible to me. However, I'm mostly confused because although my driver mimics the…
FutureShocked
  • 779
  • 1
  • 10
  • 26
3
votes
2 answers

Why is valgrind memcheck not finding errors?

I havent used valgrind before but I think it should detect some memory errors. My code: #include unsigned int a[2]; int main() { a[-1] = 21; printf("%d,", a[-1]); return 1; } As you can see, I am accessing a[-1] which I…
kkica
  • 4,034
  • 1
  • 20
  • 40
3
votes
1 answer

Ignore part of code with valgrind - memcheck

I use massif, sgcheck and memcheck valgrind's modules to check a c/c++ project. I would like to know if it is possible to make valgrind ignore part of code. When I run it on my project I have something like 248 different "false" errors generated by…
Bastienm
  • 363
  • 2
  • 16
3
votes
1 answer

Fortran90 valgrind output help. Unexplained error happening at the beginning of code execution

I am currently writing a large non-linear solver for a nasty partial differential equation in Fortran90 as part of my research. I have run into an issue where I believe a memory corruption issue is plaguing my code and I am trying to track it down;…
3
votes
7 answers

Valgrind claims there is unfreed memory. Is this bad?

Valgrind gives me the following leak summary on my code. However, I have freed all malloc'ed memory. Is this a bad thing, or is this normal? My program is in c. ==3513== LEAK SUMMARY: ==3513== definitely lost: 0 bytes in 0 blocks. ==3513== …
Ritwik Bose
  • 5,889
  • 8
  • 32
  • 43
3
votes
2 answers

CUDA racecheck, shared memory array and cudaDeviceSynchronize()

I recently discovered the racecheck tool of cuda-memcheck, available in CUDA 5.0 (cuda-memcheck --tool racecheck, see the NVIDIA doc). This tool can detect race conditions with shared memory in a CUDA kernel. In debug mode, this tool does not detect…
BenC
  • 8,729
  • 3
  • 49
  • 68
3
votes
3 answers

how do i valgrind memcheck on every instance of Process without starting it via valgrind command options

how do i do a valgrind memcheck on every instance of Process without starting it via valgrind command options. Is there a way to keep the monitoring options saved on a process rather than starting up the process every-time with valgrind command? In…
Vijay
3
votes
2 answers

Nvidia CUDA - passing struct by pointer

I have a problem with passing a pointer to the struct to the device function. I want to create a struct in local memory (i know it's slow, it's just an example) and pass it to the other function by pointer. The problem is that when i debug it with…
unnamed
  • 41
  • 4
2
votes
1 answer

How to detect memory leaks in a dll library?

I have d7 and dll library. How can i attach the memcheck to that library, that I could detect memory leaks in it?
John
  • 1,834
  • 5
  • 32
  • 60
2
votes
1 answer

How do I compile the source code for ADB (Android Debug Bridge)?

I'm trying to run a memory error detector (like Valgrind's Memcheck or Drmemory) on the ADB software. However, I'm having trouble figuring it how to build/compile the source code. I'm using linux…
bbqsasuke
  • 21
  • 1
  • 3
2
votes
1 answer

Tool for valgrind memcheck xtree file

I am trying to find the correct tool for displaying the results contained in the file generated by : valgrind --tool=memcheck --xtree-memory=full --xml=yes --xml-file=memcheck_result.xml [prog] This produces a file named xtmemory.kcg.[pid] which is…
Simon
  • 2,208
  • 4
  • 32
  • 47
2
votes
0 answers

A warning "WARNING: linker: "vgpreload_core-arm64-linux.so" has unsupported flags DT_FLAGS_1=0x421" came when executing Valgrind in Android

I have tried to run Valgrind MemCheck in Android Orea 8.1 using adb shell. But initially it gave many errors, I have hacked into it till this point. Now am getting this error. Valgrind has been deprecated from AOSP. But I needed to use memcheck on…
2
votes
3 answers

Access User variables from Valgrind source code

I am trying to do some experiment with valgrind source code. I am using the below code as my test code: #include int g_int = 12; int main() { int y = 10; int x; printf("%d\n",x); return x; } I build a executable named "test.out".…
kayas
  • 703
  • 1
  • 5
  • 14