valgrind

strdup(): Confused about warnings ('implicit declaration', 'makes pointer…without a cast', memory leak)

Deadly 提交于 2019-12-12 14:23:40
问题 When I compile the short piece of code below (in which we define a string and then use strdup to make a copy), I get 3 warnings: 2 compiler warnings from GCC and 1 run-time warning/error from valgrind. I suspect the memory leak error (reported by valgrind) is also related to my use of strdup, which is why I'm including the relevant output below. What am I doing wrong? (I'm working my way through a C book and this is how strdup is used by the author.) The code: #include <stdio.h> #include

C malloc valgrind invalid write of size

五迷三道 提交于 2019-12-12 13:26:47
问题 I've had my fair share malloc invalid writes (and the many examples on this site) but I still have trouble pointing out what's causing some. Here I have an adjacency matrix to use for graphs and when allocating, I get the invalid write from valgrind (but no segmentation fault throughout the program). I also get invalid reads but I assume that's caused from the invalid write prior. FYI adj_matrix is a typedef'd struct with an int type for number of vertices and a char** for the actual 2D array

“Backtrace stopped: previous frame identical to this frame (corrupt stack?)” on ARM linux

爷,独闯天下 提交于 2019-12-12 12:51:11
问题 I am trying to debug a segfault while running an application on linux ( ARM architecture). I copied the core dump file and tried to get the backtrace using arm-gdb on x86_64 host. This is the o/p: $ arm-arago-linux-gnueabi-gdb test_slave6_slave core GNU gdb (GDB) 7.4 Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the

Can I get valgrind to tell me _which_ value is uninitialized?

最后都变了- 提交于 2019-12-12 12:18:47
问题 I ran valgrind on some code as follows: valgrind --tool=memcheck --leak-check=full --track-origins=yes ./test It returns the following error: ==24860== Conditional jump or move depends on uninitialised value(s) ==24860== at 0x4081AF: GG::fl(M const&, M const&) const (po.cpp:71) ==24860== by 0x405CDB: MO::fle(M const&, M const&) const (m.cpp:708) ==24860== by 0x404310: M::operator>=(M const&) const (m.cpp:384) ==24860== by 0x404336: M::operator<(M const&) const (m.cpp:386) ==24860== by

Running Eclipse under Valgrind

痴心易碎 提交于 2019-12-12 12:00:21
问题 Has anybody here succeeded in running Eclipse under Valgrind? I'm battling a particularly hairy crash involving JNI code, and was hoping that Valgrind perhaps could (again) prove its excellence, but when I run Eclipse under Valgrind, the JVM terminates with an error message about not being able to create the initial object heap (I currently don't have access to the exact error message; I'll edit this post as soon as I do.) 回答1: If there is a crash in native code, then gdb might be a better

Building valgrind on OS X

ぐ巨炮叔叔 提交于 2019-12-12 08:47:24
问题 I was trying to install valgrind on macOS Sierra (version 10.12.6). While running ./configure.sh, this error showed up: checking for a supported version of gcc... Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 no (applellvm-8.1.0) configure: error: please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0 So, I checked my

How can I use valgrind for memory profile

杀马特。学长 韩版系。学妹 提交于 2019-12-12 08:38:24
问题 Can you please tell me how can I use valgrind for memory profile? The article I found from google talks about how to use valgrind for memory leak. I am interested in how to use that for memory profiling (i.e. how much memory is used by what classes)? Thank you. 回答1: You can use valgrind's Massif tool to get a heap profile. This code is still labelled "experimental", and it does not ship with all versions of valgrind. You may have to download and build from source. Also note that the heap

valgrind - Find memory leak in a shared library

十年热恋 提交于 2019-12-12 08:24:57
问题 I need to know ways to find out the memory leaks in a shared library which will be loaded to a release binary. I mean shared library I built with -g option but the binary that loads the shared library is not built with -g option. I get the leak report as follows. ==739== at 0x4A05809: malloc (vg_replace_malloc.c:149) ==739== by 0x84781B1: ??? ==739== by 0x87507F5: ??? ==739== by 0x874CF47: ??? ==739== by 0x874E657: ??? ==739== by 0x874F7C2: ??? ==739== by 0x8779C0C: ??? Please let me know how

Valgrind - snprintf : Conditional jump or move depends on uninitialised value(s)

本小妞迷上赌 提交于 2019-12-12 04:16:39
问题 After launching a program thru valgrind I got the following message : ==9290== Conditional jump or move depends on uninitialised value(s) ==9290== at 0x4E82A03: vfprintf (vfprintf.c:1661) ==9290== by 0x4EA9578: vsnprintf (vsnprintf.c:119) ==9290== by 0x4E8B531: snprintf (snprintf.c:33) ==9290== by 0x400820: _function (in /home/snp/prog/TEST) ==9290== by 0x4006D5: start (in /home/snp/prog/TEST) ==9290== by 0x40085C: main (in /home/snp/prog/TEST) ==9290== Uninitialised value was created by a

Segfault in c++ program; Incomprehensible valgrind output

折月煮酒 提交于 2019-12-12 03:29:42
问题 I'm currently writing my first big c++-project but encountered a segmentation fault when running the program. I already tried to debug it using valgrind, but so far without success. Since the program is quite big, I'll show only the relevant function in which the error occured: void RigidBody::RotateAroundAxis( dReal Angle, dRealVector3 Axis, dRealVector3 Anchor) { std::cout<<"RotateAroundAxis BodyID: " << this->GetBodyId()<<std::endl; dRealMatrix3 RotationMatrix=HelperFunctions: