valgrind

Memory leak when assigning allocatable polymorphic variable with return value

若如初见. 提交于 2021-02-20 00:48:58
问题 I'm struggling with memory management or correct usage of object oriented Fortran 2008. My code has multiple derived types with the same parent (here Example01 and Example02 ) stored in a Example_Class module. I want to load one example in a subroutine workenv depending on some variable (here idx_example ). Whichever one is chosen should be accessed by procedures defined in the base class, so I can do call active_Example%Info() regardless of what active_Example is. The following code compiled

Memory leak when assigning allocatable polymorphic variable with return value

人走茶凉 提交于 2021-02-20 00:46:35
问题 I'm struggling with memory management or correct usage of object oriented Fortran 2008. My code has multiple derived types with the same parent (here Example01 and Example02 ) stored in a Example_Class module. I want to load one example in a subroutine workenv depending on some variable (here idx_example ). Whichever one is chosen should be accessed by procedures defined in the base class, so I can do call active_Example%Info() regardless of what active_Example is. The following code compiled

How to characterize a workload by obtaining the instruction type breakdown?

醉酒当歌 提交于 2021-02-15 07:44:35
问题 I want to obtain the percentage of memory read-write instructions in a test program, preferably dynamically. Apart from counting instructions in the gdb asm dump, which is static anyway, is there an easier way to obtain it? Valgrind provides total heap usage. Perf has some nice features but does not support WSL. Pin has an instruction count capability but it I am not sure if it supports WSL. 回答1: (Update: PIN reportedly doesn't work under WSL. But it doesn't require perf counters so it's

Waiting for system call to finish

人盡茶涼 提交于 2021-02-10 20:37:16
问题 I've been tasked to create a program that takes a text file that contains a list of programs as input. It then needs to run valgrind on the programs (one at a time) until valgrind ends or until the program hits a max allotted time. I have the program doing everything I need it to do EXCEPT it isn't waiting for valgrind to finish. The code I'm using has this format: //code up to this point is working properly pid_t pid = fork(); if(pid == 0){ string s = "sudo valgrind --*options omitted*" +

Invalid write of size 8, C Valgrind, string arrays

房东的猫 提交于 2021-02-08 15:52:41
问题 I have been using both valgrind and gdb and I can not quite figure out what the problem is. It hops around too much for me to really trace it down in gdb, and in valgrind I don't have enough information. Here is my makeargv function, which is putting strings outputted from strtok() into arrays. makeargv is called from the below parse function. I'm not sure where I'm going wrong. I would really appreciate the help :D. Just an FYI I'm really new to all this malloc'ing and don't really

Valgrind: fatal error: memcheck.h: No such file or directory

醉酒当歌 提交于 2021-02-08 14:17:46
问题 We are trying to track down a Conditional jump or move depends on uninitialised value in a C++ project reported by Valgrind. The address provided in the finding is not really helpful because it points to the end of a GCC extended assembly block, and not the actual variable causing the trouble. According to the Valgrind's Eliminating undefined values with Valgrind, the easy way, we can use VALGRIND_CHECK_MEM_IS_DEFINED or VALGRIND_CHECK_VALUE_IS_DEFINED after including <memcheck.h> .

How to make valgrind ignore certain line?

末鹿安然 提交于 2021-02-08 06:28:31
问题 for example ==26460== 2 bytes in 1 blocks are still reachable in loss record 2 of 105 ==26460== at 0x4C28BE3: malloc (vg_replace_malloc.c:299) ==26460== by 0x580D889: strdup (in /usr/lib64/libc-2.17.so) ==26460== by 0x4F50AF: init (init.c:468) ==26460== by 0x406D75: main (main.c:825) I want to not check init.c:468: mode = strdup , i'm sure this only malloc once, and will last whole process life. Is it possible to make valgrind not check this line? 回答1: As I said in my comment: I recommend not

Is bash leaking memory?

一笑奈何 提交于 2021-02-08 05:55:09
问题 I'm running bash v4.4.19(1)-release on Ubuntu 18.10. If I run valgrind on a simple script (or even bash --version ), I'm seeing that I definitely lost 12 bytes of memory and there's on the order of 46kB still reachable. The still reachable memory doesn't bother me so much since I know bash is going to do it's thing with process handling and deallocation, but what I don't understand is why I'm losing these 12 bytes. Here's an example of a simple test script I'm using (filename is t.bash): #!

Mmap and valgrind, mmap doesnt increase heap size

99封情书 提交于 2021-02-07 20:28:34
问题 I'm attending operating systems course on my university, one of the tasks we were given is to implement simple malloc using mmap. Now that i got it working i tried to use valgrind to detect any bugs left. And regarldess of freeing memory or not, valgrind doesnt see any memory leaks. As an example consider following C code: int main() { int psize = getpagesize(),i; int *ptr = mmap(NULL, psize, PROT_WRITE | PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); for(i = 0; i < psize/4; i++) ptr[i] = i;

Mmap and valgrind, mmap doesnt increase heap size

拟墨画扇 提交于 2021-02-07 20:25:59
问题 I'm attending operating systems course on my university, one of the tasks we were given is to implement simple malloc using mmap. Now that i got it working i tried to use valgrind to detect any bugs left. And regarldess of freeing memory or not, valgrind doesnt see any memory leaks. As an example consider following C code: int main() { int psize = getpagesize(),i; int *ptr = mmap(NULL, psize, PROT_WRITE | PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); for(i = 0; i < psize/4; i++) ptr[i] = i;