valgrind

valgrind detects memory leak but application works

China☆狼群 提交于 2019-12-11 04:12:41
问题 I wrote an application able to read in sqlite database thanks to this function: struct query_res excucute_sql_statement(char *database, char *zSQL){ sqlite3 *conn; sqlite3_stmt *res; const char *tail, *buf, *zErrMsg; struct query_res q_res; char table[MAXSTMTNUM][MAXCOLNUM][MAXSTRINGLEN]; q_res.table = table; q_res.num = 0; int maxtry = 5, try = 0; while (sqlite3_open(database, &conn)) { if (try > maxtry) break; printf("Can not open database \'%s\'. %s\n", database, sqlite3_errmsg(conn));

gdb and valgrind within a makefile

房东的猫 提交于 2019-12-11 03:54:48
问题 I have a very basic question. I did look around like over here http://www.cs.cmu.edu/~gilpin/tutorial/ but still doubtfull.. Consider the following makefile(had also given it in a previous question) all: clients.so simulator backup LD_PRELOAD=/home/Juggler/client/clients.so ./simulator backup: backup.c libclient.a gcc backup.c -o backup -L /home/Juggler/client -L. -lclient -ldl simulator: simulator.c libclient.a gcc -g simulator.c -o simulator -L /home/Juggler/client -L. -lclient -ldl

std::remove_copy_if_ valgrind bytes in block are possibly lost in loss record

爱⌒轻易说出口 提交于 2019-12-11 03:12:47
问题 Exploring a valgrind report in search of a huge memleak, it seems that the following line produces the biggest threat over lots of calls: std::remove_copy_if(raw_word.begin(), raw_word.end(), std::back_inserter(word), std::ptr_fun<int, int>(&std::ispunct)); CODE char * payload = /* acquire somehow */ int whitespace; char * p_word = NULL; for(whitespace = 0; whitespace < payload_len; whitespace ++) { if(isspace(payload[whitespace])) { payload[whitespace] = 0; if(p_word != NULL) { std::string

Still reachable with puts and printf

时光怂恿深爱的人放手 提交于 2019-12-11 03:12:26
问题 Valgrind is reporting the still reachable "error" on functions like printf and puts. I really don't know what to do about this. I need to get rid of it since it's a school project and there has to be no errors at all. How do I deal with this? From the report I can see those functions use malloc , but I always thought they handled the memory by themselves, right? I'm using mac OS X so maybe it's a problem between valgrind and the OS? SAMPLE CODE: The error appears on any of the puts or printf

How to pass arguments to memcheck with ctest?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 03:06:10
问题 I want to use ctest from the command line to run my tests with memcheck and pass in arguments for the memcheck command. I can run ctest -R my_test to run my test, and I can even run ctest -R my_test -T memcheck to run it through memcheck. But I can't seem to find a way to pass arguments to that memcheck command, like --leak-check=full or --suppressions=/path/to/file . After reading ctest's documentation I've tried using the -D option with CTEST_MEMCHECK_COMMAND_OPTIONS and MEMCHECK_COMMAND

Valgrind debug log: Invalid read of size 8

最后都变了- 提交于 2019-12-11 02:43:38
问题 recently I decide to debug my application with valgrind. I've resolved a lot of errors, but can't this one. ==12205== Invalid read of size 8 ==12205== at 0x37E1864C40: std::_Rb_tree_increment(std::_Rb_tree_node_base*) (in /usr/lib64/libstdc++.so.6.0.8) ==12205== by 0x40393C: readConfig(std::string) (stl_tree.h:257) ==12205== by 0x4058BE: main (application.cpp:42) ==12205== Address 0x5589b88 is 24 bytes inside a block of size 48 free'd ==12205== at 0x4A05A33: operator delete(void*) (vg_replace

Why does Valgrind show no allocations for a Rust program?

社会主义新天地 提交于 2019-12-11 01:02:32
问题 I'm learning Rust and I was playing with Box , so I tried checking leaks with valgrind but it shows that there are no allocations on the heap: $ rustc -C opt-level=0 raii.rs $ valgrind ./raii ==3850== Memcheck, a memory error detector ==3850== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==3850== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info ==3850== Command: ./raii ==3850== 5 Changed:10 ==3850== ==3850== HEAP SUMMARY: ==3850== in use at exit: 0 bytes

localtime_r consuming some memory before program exit

六眼飞鱼酱① 提交于 2019-12-11 00:54:44
问题 I use valgrind's massif to track memory usage at the last stage before program exit and found js::DateTimeInfo::updateTimeZoneAdjustment() (DateTime.cpp:19) which is calling localtime_r and consuming some memory. 16 ComputeLocalTime(time_t local, struct tm *ptm) 17 { 18 #ifdef HAVE_LOCALTIME_R 19 return localtime_r(&local, ptm); 20 #else 21 struct tm *otm = localtime(&local); 22 if (!otm) ms_print of last snapshot from valgrind's massif 427711 -------------------------------------------------

valgrind and pthreads (on os x El Capitan): can't make a smallest working example?

烈酒焚心 提交于 2019-12-11 00:26:20
问题 A pthreads program seems to work fine for me on El Capitan, but when I run with valgrind I get a SIGSEGV crash 'Access not within mapped region at address 0x700002F32C05' from within pthread_join. The stacktrace differs slightly, based on whether I'm trying to access a return-value from the thread or not (ends in _pthread_find_thread vs _OSSpinLockLockSlow ). My question: Am I mis-understanding how to use pthreads, or is this a valgrind-on-Yosemite issue? (Or, something else?) I'm running

C++ valgrind possible leaks on STL string

守給你的承諾、 提交于 2019-12-11 00:16:28
问题 I do not see the reason of the leak below. #include <iostream> #include <cstdlib> int fail(const std::string str) { std::cerr<< str << std::endl; exit(1); } const std::string usage() { std::string a = "a"; return a; } int main() { fail(usage()); return 0; } Valgrind says: ==7238== 14 bytes in 1 blocks are possibly lost in loss record 1 of 1 ==7238== at 0x402377E: operator new(unsigned) (vg_replace_malloc.c:224) ==7238== by 0x40E7C03: std::string::_Rep::_S_create(unsigned, unsigned, std: