valgrind

pinpointing “conditional jump or move depends on uninitialized value(s)” valgrind message

帅比萌擦擦* 提交于 2019-12-17 03:49:16
问题 So I've been getting some mysterious uninitialized values message from valgrind and it's been quite the mystery as of where the bad value originated from. Seems that valgrind shows the place where the unitialised value ends up being used, but not the origin of the uninitialised value. ==11366== Conditional jump or move depends on uninitialised value(s) ==11366== at 0x43CAE4F: __printf_fp (in /lib/tls/i686/cmov/libc-2.7.so) ==11366== by 0x43C6563: vfprintf (in /lib/tls/i686/cmov/libc-2.7.so) =

longest common subsequence: why is this wrong?

这一生的挚爱 提交于 2019-12-14 03:55:55
问题 int lcs(char * A, char * B) { int m = strlen(A); int n = strlen(B); int *X = malloc(m * sizeof(int)); int *Y = malloc(n * sizeof(int)); int i; int j; for (i = m; i >= 0; i--) { for (j = n; j >= 0; j--) { if (A[i] == '\0' || B[j] == '\0') X[j] = 0; else if (A[i] == B[j]) X[j] = 1 + Y[j+1]; else X[j] = max(Y[j], X[j+1]); } Y = X; } return X[0]; } This works, but valgrind complains loudly about invalid reads. How was I messing up the memory? Sorry, I always fail at C memory allocation. 回答1: The

Does glib2 actually leak memory with ALWAYS-MALLOC?

自古美人都是妖i 提交于 2019-12-14 03:52:48
问题 This question is not a duplicate of many others, bekause I do use G_DEBUG=gc-friendly and G_SLICE=always-malloc Here is the source code: #include <glib.h> int main (int argc, char *argv[]) { GHashTable *ht; ht=g_hash_table_new(g_str_hash,g_str_equal); g_hash_table_insert(ht,"foo","bar"); g_hash_table_destroy(ht); return 0; } And here is Valgrind's output on this code: # G_DEBUG=gc-friendly G_SLICE=always-malloc valgrind --leak-check=full --show-reachable=yes ./test_vg ==1880== Memcheck, a

Interpreting valgrind output for a C++/SDL2 program

北慕城南 提交于 2019-12-14 03:22:30
问题 Hi can somebody please explain what this valgrind output means and how I should go about fixing this ?? The output I am posting currently is a part of the actual terminal output. The rest is also similar and mostly the same errors are listed. This is for a C++ program using SDL2. The relevant code is really long so I will add whatever is asked in comments. Is this happening due to some SDL_Surface* s? But I made sure to free all of those before returning from main(). Also, my SDL_Window* is

gcc / C++ Disable generation of vex instructions

岁酱吖の 提交于 2019-12-14 03:21:35
问题 We are debugging memory issues with our large legacy app and would like to use Valgrind to track it down. The app uses the ACE/TAO CORBA library however, Valgrind complains of illegal "vex" instructions in the library. ==29992== Memcheck, a memory error detector ==29992== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. ==29992== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info ==29992== Command: DvMain ==29992== DvMain. Version 6.0 Build 38B16 vex x86->IR:

valgrind reporting 'Invalid read' *entirely within still-allocated block*

↘锁芯ラ 提交于 2019-12-13 16:11:50
问题 I'm seeing a truly baffling series of error reports from Valgrind's Memcheck tool: ==29456== Invalid read of size 8 ==29456== at 0x4D5C90: CkIndex_Ping1::_callthr_trecv_PingMsg(CkThrCallArg*) (in /scratch/phil/charm/net-linux-x86_64-bigsim/tests/charm++/pingpong/pgm) ==29456== by 0x503ECB: CthStartThread (libthreads-default.c:1690) ==29456== by 0x56A08AF: ??? (in /lib/x86_64-linux-gnu/libc-2.19.so) ==29456== Address 0x5b09a90 is 0 bytes inside a block of size 16 alloc'd ==29456== at 0x4C2B0E0

Valgrind malloc leaks

眉间皱痕 提交于 2019-12-13 14:39:55
问题 I'm writing a program to search though directories for a requested file. The output on command line will be the path of the directory to the file, for each file found with the same name. For some reason it is giving memory leaks when I run it with valgrind. I am running on a linux virtual machine on a windows box. I updated my valgrind output. I have no leaks free leaks but still errors. Here's my code: #include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <sys/types.h> #include

Valgrind reporting that getaddrinfo is leaking memory?

こ雲淡風輕ζ 提交于 2019-12-13 14:29:32
问题 I've been running Valgrind on our project, and valgrind has been reporting that memory had been lost from a call to getaddrinfo, despite freeaddrinfo having been called at the bottom of the function. Any idea what might be causing this? int tcp_connect(char *address, char *port) { //printf("%s\n ", address); int status, sockfd; struct addrinfo hints, *servinfo, *p; memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype= SOCK_STREAM; status = getaddrinfo(address,port,

What can cause strange addresses in a Valgrind stack trace?

断了今生、忘了曾经 提交于 2019-12-13 13:46:16
问题 (This question is related to Filtering out junk from valgrind output). I'm trying to debug memory leaks in a large project that is mostly out of my hands --- it's a fork of a codebase that's on the order of millions of lines of code, although most of it probably isn't relevant to the small section that I'm working on. Since it would be very tough to look through it by hand, I'm trying to use valgrind to track down the leaks. The problem is that the stack traces look like this: ==83597== 920

Valgrind reports a memory error when trying to free a malloc'ed struct

不羁的心 提交于 2019-12-13 12:21:43
问题 Valgrind always nags that there is a memory error when a previously malloc'ed struct is free'd. The struct looks as follows: typedef struct bullet { int x, y; struct bullet * next; } BULLET; ... and I allocate the memory by using BULLET * b; b = malloc(sizeof(BULLET)); // sizeof(BULLET) is 16 and later on, the struct is free'd by simply calling free(b); . Valgrind however doesn't seem to be satisfied by this, and so it tells me ==2619== Invalid read of size 8 ==2619== at 0x40249F: ctrl