valgrind

To allocate or not to allocate. Invalid read of size 1 errors. [Staring for 2 hours]

末鹿安然 提交于 2019-12-23 05:02:05
问题 This is the code I'm working on code However there are problems. Some or all might be because of not allocating space for data in nodes (line 135~) because the line is changing during iteration in main . But when I allocate space for it, at line 135, the outcome doesn't change much and there is memory leak. I'm stuck. I'm about to go crazy. Can you help me to fix errors? Any help is appreciated. Thank you! Output: a@ubuntu:~/os/hw1$ ./o f1.txt f2.txt o.txt *** Error in `./o': double free or

How do I run Valgrind on a program that needs superuser permission?

拟墨画扇 提交于 2019-12-23 04:58:06
问题 I'm writing a packet sniffer in C (using libpcap) and I can't use Valgrind to find memory leaks in my program as it must be run with superuser permissions, because, without this, I can't even open the network interface for capture. When I try to run Valgrind with sudo , I got this: $ valgrind sudo ./[exec] ==5211== ==5211== Warning: Can't execute setuid/setgid/setcap executable: /usr/bin/sudo ==5211== Possible workaround: remove --trace-children=yes, if in effect ==5211== valgrind: /usr/bin

How to install valgrind good?

和自甴很熟 提交于 2019-12-23 00:51:22
问题 I'm installing valgrind now, until the ‘make install’ command it goes good. The next command- ‘make regtest’ outputs the next error: ../../depcomp: line 689: exec: g++: not found make[5]: *** [leak_cpp_interior.o] Error 127 make[5]: Leaving directory `/home/kbubuntu/valgrind-3.9.0/memcheck/tests' make[4]: *** [check-am] Error 2 make[4]: Leaving directory `/home/kbubuntu/valgrind-3.9.0/memcheck/tests' make[3]: *** [check-recursive] Error 1 make[3]: Leaving directory `/home/kbubuntu/valgrind-3

Problems with memory dynamic allocation: main: malloc.c:3096: sYSMALLOc

风流意气都作罢 提交于 2019-12-22 16:54:28
问题 I'm writing a simple function to create a list which represents a deck of cards. Here's the definition of the structs typedef struct { float valoreEff; char *seme; char *valore; } carta; struct Mazzo { carta info; struct Mazzo *nextPtr; }; typedef struct Mazzo mazzo; typedef mazzo *mazzoPtr; Here's the function which returns a pointer to the first element of the list mazzoPtr caricaMazzo(void){ mazzoPtr sMazzoPtr=NULL; int val,seme; carta buffer; mazzoPtr newPtr; char *tabValori[10]={"Asso",

Why valgrind report my memory as “definitely lost”?

柔情痞子 提交于 2019-12-22 11:46:07
问题 Consider this code: #include <stdlib.h> int* alloc() { return malloc(250 * sizeof(int)); } int main() { int i; int *vars[3]; for(i = 0; i < 3; ++i) { vars[i] = alloc(); } } Valgrind output: $ valgrind --leak-check=full ./lala ==16775== Memcheck, a memory error detector ==16775== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==16775== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info ==16775== Command: ./lala ==16775== ==16775== ==16775== HEAP SUMMARY: =

How to get complete stack dump from profiler in every sample for use in flame graph?

…衆ロ難τιáo~ 提交于 2019-12-22 10:01:22
问题 I really like the idea of the Flame Graph for profiling since it will help in eliminating unneeded function calls. There is a catch however in that it requires the profiler to do a complete stack dump each time it collects a sample. This can be accomplished with DTrace or SystemTap quite easily, but I need to be able to do this on an ARM device running ubuntu (which eliminates DTrace). I would also like to do this without recompiling the kernel (which eliminates SystemTap). Is it possible to

fork with invalid command cause a memory leak in valgrind

余生颓废 提交于 2019-12-22 08:48:36
问题 I have the following code which execute a non valid command within a fork. The following code return a memory leak in valgrind. #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdarg.h> #include <errno.h> #include <unistd.h> int external_cmd(char **argv) { int pid; if ((pid = fork()) == -1) return -1; if (pid == 0) { /* child */ execvp(argv[0], argv); exit(0); } else if (pid < 0) return -1; int status; while (wait(&status) != pid); return 0; } int main () { char *argv[8]

Error summary in Valgrind output?

霸气de小男生 提交于 2019-12-22 05:33:36
问题 I have seen some of the post regarding valgrind but not single post helped me in understanding interpretation of valgrind output. I ran two programs with valgrind (Both having memory leaks) Sample Output for Test 1 ==20422== LEAK SUMMARY: ==20422== definitely lost: 448 bytes in 3 blocks ==20422== indirectly lost: 786,460 bytes in 1 blocks ==20422== possibly lost: 1,576,052 bytes in 46 blocks ==20422== still reachable: 1,077,107 bytes in 2,333 blocks ==20422== suppressed: 0 bytes in 0 blocks =

Debugging a core produced by valgrind

眉间皱痕 提交于 2019-12-22 05:08:11
问题 Valgrind produced a vgcore.NNNN file -- how do I debug the core using GDB? Do I need to use the original executable and supply the core, or is there some other way to do it? Using valgrind as the root executable doesn't seem to work, and using the executable that was being run under valgrind directly in GDB with the core seems to produce bad backtraces. 回答1: This works fine for me: gdb ./a.out vgcore.21650 and that's how you are supposed to use the vgcore. If your program corrupted stack

Is there anyway a valgrind message “Conditional jump or move depends on uninitialized value” can be a so called 'false positive'

烈酒焚心 提交于 2019-12-22 04:30:39
问题 Most questions I find here provide a piece of code and get answered by someone pointing to the actual error. My question is about conditional jumps on uninitialized values in general. I can understand that a piece of memory should not necessarily be cleaned at the end of a program if one is sure this allocation is done only once and will probably be needed during the lifetime of a program. As far as I remember the GType system leaves a lot of unfreed memory when the program terminates. These