valgrind

valgrind shows memory leak even after memory free

我与影子孤独终老i 提交于 2021-01-29 06:23:40
问题 so I have the file Countries.c which contains: typedef struct City* pCity; typedef struct Country* pCountry; typedef struct Territory* pTerritory; struct City{ char* name; char* food; int population; }; struct Country{ char *name; int numCities; pCity cities; pTerritory countryTerr; }; struct Territory{ int x1; int x2; int y1; int y2; }; void deleteCountry(pCountry country){ if(country != NULL){ int num_of_cities = country->numCities; for(int i = 0 ; i<num_of_cities; i++){ if (country->cities

Valgrind: Uninitialised value was created by a heap allocation

本秂侑毒 提交于 2021-01-28 20:22:18
问题 I'm getting a few Valgrind errors concerning Unitialised values and Conditional Jumps. Here is my Valgrind output ==28124== Conditional jump or move depends on uninitialised value(s) ==28124== at 0x4C2E0E9: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==28124== by 0x400AA7: append_character (in /home/i) ==28124== by 0x401319: refresh_address (in /home/) ==28124== by 0x402067: main (in /home/) ==28124== Uninitialised value was created by a heap allocation ==28124== at

mmap return EINVAL when run with Valgrind

旧巷老猫 提交于 2021-01-27 07:07:10
问题 My mips32 application run against Valgrind fails in mmap function. It works fine if I run separately but when I run it against valgrind it fails with EINVAL each time. void * mem = (uint32_t *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, <fd>, mmap_size); 回答1: When the client application runs against the Valgrind, the Valgrind intercepts the mmap call made by the client. It then invokes the kernel's mmap function by setting the MAP_FIXED flag and also specifies the memory location to

mmap return EINVAL when run with Valgrind

回眸只為那壹抹淺笑 提交于 2021-01-27 07:05:54
问题 My mips32 application run against Valgrind fails in mmap function. It works fine if I run separately but when I run it against valgrind it fails with EINVAL each time. void * mem = (uint32_t *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, <fd>, mmap_size); 回答1: When the client application runs against the Valgrind, the Valgrind intercepts the mmap call made by the client. It then invokes the kernel's mmap function by setting the MAP_FIXED flag and also specifies the memory location to

valgrind --trace-children=yes reports leak despite atexit cleanup

心已入冬 提交于 2021-01-27 06:09:26
问题 I'm trying to avoid false positives with valgrind, but I'm suck with a combination of atexit() and fork() , despite using --trace-children=yes . My code: #include <stdio.h> #include <unistd.h> #include <stdlib.h> static int * arr; static void cleanup() { free(arr); printf("free arr as: %p\n", (void *)arr); } int main() { arr = malloc(16 * sizeof(int)); printf("allocated arr as: %p\n", (void *)arr); atexit(cleanup); pid_t pid = fork(); if (pid == -1) { exit(1); } else if (pid == 0) { // child

valgrind --trace-children=yes reports leak despite atexit cleanup

非 Y 不嫁゛ 提交于 2021-01-27 06:09:15
问题 I'm trying to avoid false positives with valgrind, but I'm suck with a combination of atexit() and fork() , despite using --trace-children=yes . My code: #include <stdio.h> #include <unistd.h> #include <stdlib.h> static int * arr; static void cleanup() { free(arr); printf("free arr as: %p\n", (void *)arr); } int main() { arr = malloc(16 * sizeof(int)); printf("allocated arr as: %p\n", (void *)arr); atexit(cleanup); pid_t pid = fork(); if (pid == -1) { exit(1); } else if (pid == 0) { // child

install valgrind, Fatal error at startup

余生长醉 提交于 2021-01-21 06:28:48
问题 I am installing Valgrind but encounter some problems. The info of my platform: Linux xx-ThinkPad-X61 3.2.0-39-generic-pae #62-Ubuntu SMP Wed Feb 27 22:25:11 UTC 2013 i686 i686 i386 GNU/Linux I follows the installation instruction of the README file in the valgrind folder. ./configure ->make -> sudo make install. I can't understand the following reminder in the README file, I just overlooked it. Important! Do not move the valgrind installation into a place different from that specified by -

应用层内存溢出/越界/重复释放等问题检查工具(ASan)

爷,独闯天下 提交于 2020-11-21 04:04:50
https://github.com/google/sanitizers/wiki https://github.com/google/sanitizers/wiki/AddressSanitizer AddressSanitizer (aka ASan) is a memory error detector for C/C++. It finds: Use after free (dangling pointer dereference) Heap buffer overflow Stack buffer overflow Global buffer overflow Use after return Use after scope Initialization order bugs Memory leaks This tool is very fast. The average slowdown of the instrumented program is ~2x (see AddressSanitizerPerformanceNumbers ). The tool consists of a compiler instrumentation module (currently, an LLVM pass) and a run-time library which