valgrind

memory leak in dgemm_

放肆的年华 提交于 2019-12-05 18:23:05
I am currently working on an application which involves lots and lots of calls to blas routines. Routinely checking for memory leaks I discovered, that I am loosing bytes in a dgemm call. The call looks like this: // I want to multiply 2 nxn matrices and put the result into C - an nxn matrix double zero = 0.0; double one = 1.0; double n; // matrix dimension char N = 'N'; dgemm_(&N, &N, &n, &n, &n, &one, A, &n, B, &n, &zero, C, &n); A,B and C are double fields of size n*n. The valgrind output is: ==78182== 18 bytes in 1 blocks are definitely lost in loss record 2 of 30 ==78182== at 0xB936:

getpwnam_r memory leak

心不动则不痛 提交于 2019-12-05 14:44:25
I use getpwnam_r to handle client connections in my programs. Sadly enough, it seems to allocate a buffer it never frees. The relevant valgrind output: ==15774== 536 (104 direct, 432 indirect) bytes in 2 blocks are definitely lost in loss record 1 of 3 ==15774== at 0x4C24CFE: malloc (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so) ==15774== by 0x5143B5A: nss_parse_service_list (in /lib64/libc-2.10.1.so) ==15774== by 0x51442E6: __nss_database_lookup (in /lib64/libc-2.10.1.so) ==15774== by 0x57BE35F: ??? ==15774== by 0x57BF3F6: ??? ==15774== by 0x51014D2: getpwnam_r@@GLIBC_2.2.5 (in

Valgrind macOs and error Syscall param msg->desc.port.name points to uninitialised byte(s)

落花浮王杯 提交于 2019-12-05 13:56:50
问题 I tried to run valgrind 3.13 and 3.14 (on macOs 10.12.6) in very simple project but I got strange error who I never got in my linux before. Very simple C program main.c : int main() { return (0); } Compilation with cc : $> cc main.c Run my simple program with valgrind : $> valgrind ./a.out Output of valgrind: ==12768== Memcheck, a memory error detector ==12768== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==12768== Using Valgrind-3.14.0.SVN and LibVEX; rerun with -h for

getaddrinfo memory leak

こ雲淡風輕ζ 提交于 2019-12-05 11:27:46
问题 I have this code for getting information about IPv4 address: struct addrinfo hints, *info = NULL; char addr4[INET_ADDRSTRLEN]; memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; hints.ai_family = AF_INET; if (!getaddrinfo(argv[hostPara], NULL, &hints, &info)) { inet_ntop(AF_INET, &((const sockaddr_in *)info->ai_addr)->sin_addr, addr4, INET_ADDRSTRLEN); } if (info != NULL) { freeaddrinfo(info); } but if I tested argv[hostPara] is "www.google.com" I am getting this from valgrind

Debugging Symbols Lost When Linking?

醉酒当歌 提交于 2019-12-05 11:13:16
问题 I'm trying to compile a program with debugging symbols so that valgrind will give me line numbers. I have found that if I compile a simple test program in one go (with -g) then it contains the symbols. However, if I compile in two passes (i.e. compile then link) then it does not contain the debugging symbols. Here's the compile command for the single pass case: g++ -g file.c -o file And for two passes g++ -g -c file.c -o file.o g++ -g file.o -o file The actual program looks like this and

Detect C memory 'leaks' that are freed on exit

。_饼干妹妹 提交于 2019-12-05 10:05:05
Assume I have a C program (running under Linux) which manipulates many data structures, some complex, several of which can grow and shrink but should not in general grow over time. The program is observed to have a gradually increasing RSS over time (more so than can be explained by memory fragmentation). I want to find what is leaking. Running under valgrind is the obvious suggestion here, but valgrind (with --leak-check=full and --show-reachables=yes ) shows no leak. I believe this to be because the data structures themselves are correctly being freed on exit, but one of them is growing

Address 0x0 is not stack'd, malloc'd or (recently) free'd

回眸只為那壹抹淺笑 提交于 2019-12-05 09:18:55
I'm very new to C, and can't seem to figure out what's wrong with the following code. int main() { char filen[] = "file.txt"; FILE *file = fopen ( filen, "r" ); if ( file != NULL ) { char line [ 128 ]; while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */ { int i; char *result; for(i=0; i< NUM;i++) { char *rep; rep = (char *) malloc (sizeof(mychars[i][0])); strcpy(rep, mychars[i][0]); char *with; with = (char *) malloc (sizeof(mychars[i][1])); strcpy(with, cgichars[i][1]); result = (char *) malloc (sizeof(char) * 128); result = str_replace(line, rep, with); } fputs(result,

Error summary in Valgrind output?

橙三吉。 提交于 2019-12-05 08:35:41
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 ==20422== Rerun with --leak-check=full to see details of leaked memory ==20422== ==20422== For counts of

How to correctly (and effectively) release memory in a gtk widget

心已入冬 提交于 2019-12-05 07:54:53
I'm trying to understand how to correctly release memory when I am finished with a GTK widget, for example if I need to create and destroy many widgets. However, valgrind seems to indicate a memory leak regardless of what I try. I've looked at other questions, including one that lists a valgrind supression file for GTK, but it didn't change the result. Here's the simplest code snippet to reproduce my issue: #include "gtk/gtk.h" int main() { GtkWidget * widget = gtk_fixed_new(); g_object_ref(widget); g_object_ref_sink(widget); // remove floating reference, and own this object ourselves g_object

linux c 内存泄露检测工具valgrind

痞子三分冷 提交于 2019-12-05 07:51:52
Linux c/c++ 上常用内存泄露检测工具有 valgrind, Rational purify 。 Valgrind 免费。 Valgrind 可以在 32 位或 64 位 PowerPC/Linux 内核上工作。 Valgrind 工具包包含多个工具,如 Memcheck,Cachegrind,Helgrind, Callgrind , Massif 。下面分别介绍个工具的作用: Memcheck 工具主要检查下面的程序错误: • 使用未初始化的内存 (Use of uninitialised memory) • 使用已经释放了的内存 (Reading/writing memory after it has been free ’ d) • 使用超过 malloc 分配的内存空间 (Reading/writing off the end of malloc ’ d blocks) • 对堆栈的非法访问 (Reading/writing inappropriate areas on the stack) • 申请的空间是否有释放 (Memory leaks – where pointers to malloc ’ d blocks are lost forever) • malloc/free/new/delete 申请和释放内存的匹配 (Mismatched use of