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

Valgrind not showing error regarding memory region overlap

In the process of testing all kinds of dynamic memory-related errors using Valgrind (or to be specific, Memcheck), I came accross a situation where, I'm creating the memory overlap intentionally, but there is no error report from Valgrind/memcheck.…
Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261
0
votes
1 answer

how to start valgrind to check one application with non-root account

how to start valgrind to check one application with non-root account? I have one application , it only start by these way: su wrt-wxx --shell=/bin/bash -c " application application .cfg >/dev/null 2>&1 &" I want to use valgrind to do memcheck. …
nick wu
  • 139
  • 1
  • 5
  • 17
0
votes
1 answer

invalid write size: memset

void readdat (int c, char **v) { char *dc; char *pdc; dc = malloc((line+1) * sizeof(char)); memset(dc, 0, (line+1) * sizeof(char)); FILE *datfile; datfile = fopen(v[3], "r"); while(fgets(dc, line, datfile) != NULL) { pdc = strtok(dc, "\t"); …
-1
votes
1 answer

Understanding Valgrind o/p

I am running memcheck using valgrind. the o/p is ==3091== 204 bytes in 17 blocks are definitely lost in loss record 1,406 of 2,299 what does it mean ? What I guess there is 204 bytes memory loss but what it meant by 17 blocks ? and how to know…
Vivek Goel
  • 22,942
  • 29
  • 114
  • 186
-1
votes
1 answer

Valgrind memcheck - get ??? instead of method names

I'm running valgrind/memcheck trying to identify a potential memory leakage that causes unexplained segmentation faults. The log shows ??? instead of method names, so the call stack is useless. All the code (libraries and executable) is compiled…
Aaron
  • 1
  • 3
-1
votes
1 answer

C++ - Valgrind: Invalid write of size 1

I have an AVL tree with string keys, and my own String class. In order to fix another issue, I had to add a copy constructor to String. However, valgrind reports an error with it. Here's the constructor: String::String(const String& s){ try { …
1 2 3 4 5 6
7