valgrind

valgrind error “Invalid read of size 4” [duplicate]

淺唱寂寞╮ 提交于 2019-12-10 21:30:05
问题 This question already exists : c++ warning: address of local variable Closed 6 years ago . Here is my program int* fun1(void) { int n=9; int *pf=&n; cout<<*pf<<endl; return pf; } int main(int argc, char *argv[]) { int *p=fun1(); cout<<*p; return 0; } Compilation and running of program doesn't give any problems but with valgrind it gives message/warning "Invalid read of size 4". Any help to resolve the warning is most welcome 回答1: n is a local variable in fun1() and is no more valid after exit

Confusing output from Valgrind shows indirectly lost memory leaks but no definitely lost or possibly lost

邮差的信 提交于 2019-12-10 21:30:04
问题 I am running valgrind on the macos x 10.8. Valgrind says on startup "==11312== WARNING: Support on MacOS 10.8 is experimental and mostly broken. ==11312== WARNING: Expect incorrect results, assertions and crashes. ==11312== WARNING: In particular, Memcheck on 32-bit programs will fail to ==11312== WARNING: detect any errors associated with heap-allocated data." Valgrind is giving this leak summary: "LEAK SUMMARY: ==11312== definitely lost: 0 bytes in 0 blocks ==11312== indirectly lost: 48

Checking fftw3 with valgrind

允我心安 提交于 2019-12-10 19:17:23
问题 In one step of my program I need to convolve an image. To do that I am using the functions provided by fftw3 . When I run valgrind on my program I get this stack trace. My function is called convolve and it runs fftw3 's fftw_plan_dft_r2c_2d two times (once on the image, once on the convolution kernel. In order to make it more readable, I removed all addresses and process IDs. HEAP SUMMARY: in use at exit: 62,280 bytes in 683 blocks total heap usage: 178,271 allocs, 177,588 frees, 36,617,058

Should I use matching (gcc) compiler optimization flags when profiling the code?

不羁的心 提交于 2019-12-10 17:49:52
问题 I am using -O3 when compiling the code, and now I need to profile it. For profiling, there are two main choices I came accross: valgrind --tool=callgrind and gprof. Valgrind (callgrind) docs state: As with Cachegrind, you probably want to compile with debugging info (the -g option) and with optimization turned on. However, in the C++ optimization book by Agner Fog, I have read the following: Many optimization options are incompatible with debugging. A debugger can execute a code one line at a

valgrind detects memory leaks when using libcurl (no ssl)

此生再无相见时 提交于 2019-12-10 17:22:39
问题 In my C program I use some basic functions of libcurl. Today I ran valgrind in order to check if I have memory leaks and valgrind went crazy reporting multiple errors. I tracked it basically down to: CURL *curl; CURLcode res; curl = curl_easy_init(); // ... curl_easy_cleanup(curl); If I remove the code that uses libcurl completely, valgrind doesnt report any errors. I already read that there are some problems using valgrind with libcurl and ssl, but I dont fetch any https urls or the like.

Valgrind missing error

℡╲_俬逩灬. 提交于 2019-12-10 16:48:26
问题 (original post was here) Consider the following clearly buggy program: #include <string.h> int main() { char string1[10] = "123456789"; char *string2 = "123456789"; strcat(string1, string2); } and suppose to compile it: gcc program.c -ggdb and run valgrind on it: valgrind --track-origins=yes --leak-check=yes --tool=memcheck --read-var-info=yes ./a.out In the result, no error is shown: ==29739== Memcheck, a memory error detector ==29739== Copyright (C) 2002-2011, and GNU GPL'd, by Julian

valgrind complaining about __mktime - is that my fault?

大憨熊 提交于 2019-12-10 16:39:35
问题 For the first time (in my new dev environment) I'm seeing valgrind complain about mktime, but I'm not sure if this is a bug in the libc library, valgrind, or my code. I'll start with the error (below) - is this enough info to explain the cause? ==3682== at 0x38ACE9A505: __mktime_internal (in /lib64/libc-2.12.so) ==3682== by 0x4D66F7: ??? ==3682== by 0x4D7611: ??? ==3682== by 0x4D23CD: ??? ==3682== by 0x4D175B: ??? ==3682== by 0x38ACE1ECDC: (below main) (in /lib64/libc-2.12.so) ==3682==

Valgrind/R is not working: “Fatal error: cannot create 'R_TempDir'”

怎甘沉沦 提交于 2019-12-10 16:24:17
问题 First of all, I'm not really skilled with these kind of stuff, so I may write stupid question, please be kind ;-) I have an R code that call a c++ code. Unfortunately, there is a problem with my code, probably memory not mapped, and i would like to use valgrind to try to understand where the error is. I already use it a couple of years ago, but now it seems to not work. When I lunch the following command R -d valgrind I get this output ==69495== Memcheck, a memory error detector ==69495==

Valgrind cannot execute memcheck tool on Android OS?

青春壹個敷衍的年華 提交于 2019-12-10 16:14:22
问题 I've compiled Valgrind for ARM using this with minor alterations. After installing on a phone with the method specified, I get the following error: # /data/local/Inst/bin/valgrind valgrind: failed to start tool 'memcheck' for platform 'arm-linux': Permission denied On closer investigation, it is possible to find what it's trying to do: # /data/local/Inst/bin/valgrind -d -v --25068:1:debuglog DebugLog system started by Stage 1, level 1 logging requested --25068:1:launcher no tool requested,

cross-compiled Valgrind does not detect obvious leaks

萝らか妹 提交于 2019-12-10 15:32:08
问题 I cross compiled Valgrind to openwrt x86 platform. It doesn't detect any leaks when running on target. On Ubuntu, it works fine. My test program is simple main() { char *p = malloc(10000); *(p-1) = 1; } Relevant compilation steps i486-openwrt-linux-uclibc-gcc -c -o leak.o -pipe -march=i486 -fhonour-copts -I/home/r2/external/openwrt/staging_dir/target-i386_uClibc-0.9.30.1/usr/include -I/home/r2/external/openwrt/staging_dir/target-i386_uClibc-0.9.30.1/include -I/home/r2/external/openwrt/staging