valgrind

How to resolve dyld and localtime leaks when profiling a project?

时光总嘲笑我的痴心妄想 提交于 2020-01-04 03:23:12
问题 I am profiling my source. I see some allocations that are still alive at exit when I run valgrind . Here is the summary: $ valgrind --track-origins=yes --show-reachable=yes --leak-check=full $BINARY ... ==20235== LEAK SUMMARY: ==20235== definitely lost: 0 bytes in 0 blocks ==20235== indirectly lost: 0 bytes in 0 blocks ==20235== possibly lost: 0 bytes in 0 blocks ==20235== still reachable: 20,228 bytes in 37 blocks ==20235== suppressed: 0 bytes in 0 blocks ==20235== The responsible libraries

C: Segmentation fault: GDB: <error reading variable>

孤人 提交于 2020-01-04 01:36:12
问题 I have a function shortestPath() that is a modified implementation of Dijkstra's algorithm for use with a board game AI I am working on for my comp2 class. I have trawled through the website and using gdb and valgrind I know exactly where the segfault happens (actually knew that a few hours ago), but can't figure out what undefined behaviour or logic error is causing the problem. The function in which the problem occurs is called around 10x and works as expected until it segfaults with GDB:

Testing iPhone app with Valgrind

烂漫一生 提交于 2020-01-03 00:55:09
问题 I have terrific bug "object was modified after being freed", so I tend to take valgrind. After successfull installation from their svn, doing little trick from here: http://landonf.bikemonkey.org/code/iphone/iPhone_Simulator_Valgrind.20081224.html and changing path to valgrind with my one, I get "Debugger terminated." with gdb log: [Session started at 2010-08-03 10:47:25 +0500.] GNU gdb 6.3.50-20050815 (Apple version gdb-1469) (Wed May 5 04:36:56 UTC 2010) Copyright 2004 Free Software

Magic numbers when debugging with gcc/g++/gdb/valgrind?

微笑、不失礼 提交于 2020-01-02 09:19:40
问题 Microsoft's Visual C++ fills memory with 'magic numbers' if it hasn't been initialized by the programmer itself. This helps with debugging of uninitialized memory. (In Visual Studio C++, what are the memory allocation representations?, 0xDEADBEEF vs. NULL) Is there a similar function when using linux GNU tools (g++/gdb)? Thanks! 回答1: You can override the C++ operator new to set allocations to your preferred byte pattern: void* operator new(size_t size) { void* mem = malloc(size); if (!mem) {

Eclipse CDT setup for valgrind + gdb

 ̄綄美尐妖づ 提交于 2020-01-01 11:32:27
问题 How can I debug a valgrind run with gdb in Eclipse? I start the program like this: Terminal A: valgrind vgdb=yes --vgdb-error=0 ./a.out It can debug it from another terminal like this: Terminal B: gdb ./a.out target remote |vgdb But I can't get this to work in Eclipse... So, I want to do graphically in Eclipse what I can do via command line in terminal B. I tried many ways to set up debug configurations in Eclipse, but I can't get it to work. The closest I got was via "C++ Attach to

Valgrind reports uninitialized values on empty C program

时间秒杀一切 提交于 2020-01-01 08:02:07
问题 I have this C program compiled with either gcc test.c or clang test.c : int main (void) { return 0; } valgrind ./a.out gives me this: ==9232== Memcheck, a memory error detector ==9232== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. ==9232== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==9232== Command: ./a.out ==9232== ==9232== Conditional jump or move depends on uninitialised value(s) ==9232== at 0x4017876: index (in /usr/lib/ld-2.16.so) ==9232== by

Valgrind's massif tool will not profile my application

久未见 提交于 2020-01-01 07:39:40
问题 I am developing a statically-linked 64-bit C++ application on 64-bit CentOS 5.8 using the standard gcc 4.4 packages from the CentOS repositories. It appears to be using more memory than I expected, so I tried using massif to profile the memory usage. I have compiled with debug information and then run valgrind --tool=massif ./MyProg from the directory where MyProg resides. It never produces any results other than the following massif.out.XXXX example. desc: (none) cmd: ./MyProg time_unit: i #

Building Valgrind for Android

我的梦境 提交于 2020-01-01 05:59:33
问题 Building valgrind-3.8.1 on ubuntu 12.04 with ndk-r6 or ndk-r8d failed with following error: ... cc1: Error: not rekognized option "-marm" priv/main_globals.c:1:0: Error: wrong Value (cortex-a8) for -mtune=switch ... My build-script: export NDKROOT=/home/stefan/android-ndk-r6-crystax-2 export HWKIND=generic PATH=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin:$PATH PATH=$PATH:$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/libexec/gcc/arm-linux

std::string operator+() memory leak?

喜欢而已 提交于 2020-01-01 04:17:15
问题 I'm quite worry because I wrote a little application and it seems that there is a memory leak if I believe valgrind (What I actually do): ==9321== 251 bytes in 7 blocks are definitely lost in loss record 1 of 1 ==9321== at 0x402569A: operator new(unsigned int) (vg_replace_malloc.c:255) ==9321== by 0x40D3D05: std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.13) ==9321== by 0x40D4977: std::string::_Rep::_M_clone(std::allocator

Valgrind - Can't understand error output

不想你离开。 提交于 2019-12-31 03:37:28
问题 I'm sorry if i eventually do something wrong. Ok my problem is the following: I just coded something very easy, but when you take a look at the Valgrind error output it just confuses me. Code: #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int num1 = 100; double num2 = 1.2; printf("Number 1 one is: %d.\n Number two is: %f.\n", num1, num2); return 0; } Valgrind error report: $ valgrind --leak-check=full ./yaq ==50642== Memcheck, a memory error detector ==50642==