valgrind

How to make Valgrind debugger step through a program

帅比萌擦擦* 提交于 2019-12-09 15:01:01
问题 Good morning, I am trying to use the Valgrind debugger to step through a program. My valgrind command line is valgrind -tool memcheck --leak-check=full --db-enable=yes ./MatchUpAcurate.exe. I am using valgrind-3.5.0 on Centos Linux release 5.5 with gdb version 7,0.1-23.el5_5.2. I enter Yes when valgrind asks the question Attach to Debugger. Then, the valgrind debugger returns with: 4428: return new tuple2<int,A>(2, i++, p->next()); When I try to use the gdb step or continue command, valgrind

valgrind - Address -— is 0 bytes after a block of size 8 alloc'd

喜你入骨 提交于 2019-12-09 14:05:37
问题 First, I know similar questions have been asked. However, I'd like to have a more general simple question with really primitive C data types. So here it is. In main.c I call a function to populate those string: int main (int argc, char *argv[]){ char *host = NULL ; char *database ; char *collection_name; char *filename = ""; char *fields = NULL; char *query = NULL; ... get_options(argc, argv, &host, &database, &collection_name, &filename, &fields, &query, &aggregation); Inside get_options :

How to do memory check on a daemon program?

做~自己de王妃 提交于 2019-12-09 05:34:31
问题 I have written a C++ application, that runs forever until terminated manually. It monitors other important applications. As a result my Daemon application should not go down. Keeping that in mind, I want to see if there are any memory leaks in my application. I used valgrind but since this application keeps running forever the valgrind does not exit. if I do a control - C then I don't get complete info from the valgrind logfile. Is there a tool that can do what Valgrind does? 回答1: I believe

Valgrind errors in c libraries?

心已入冬 提交于 2019-12-08 20:18:10
问题 Valgrind is showing an uninitialised value of size 8 error. And occasionally, the below conditional jump on uninitialised value error. All I'm doing is printing a formatted string using the stdc++ library that comes with gcc and the built in vsnprintf. This is inside a method called format which is part of a custom string class. What now? everything looks correct. Error seems to be inside _itoa.c. But all I can think of to do on the outside is not use this function, which is not very possible

Uninitialised value was created by a stack allocation

别说谁变了你拦得住时间么 提交于 2019-12-08 18:13:38
问题 I debugged my code using the tool Valgrind. It shows this error at this function. I have given below the error and My function. I don't know what is the problem here ? How can I rectify it ? My Error Is. Uninitialised value was created by a stack allocation at 0x80996D7: cdtojd(std::string const&) My Code is. double cdtojd(const string &cdate); double cdtojd(const string &cdate) { int dd,mm,yy; int y,m; double jd=0; //mm = atoi(cdate.substr(0,2).c_str()); //dd = atoi(cdate.substr(2,2).c_str()

Valgrind won't detect buffer overflow

a 夏天 提交于 2019-12-08 15:41:14
问题 #include <stdio.h> main() { char buf[8]; sprintf(buf,"AAAA%3s","XXssssssssXXXsssssXXX"); printf("%s\n",buf); } I expected valgrind to detect a buffer overflow with the above code. But it does not report any errors or warnings. Do I need to enable any special flags for that? 回答1: From Valgrind Tutorial What valgrind is NOT Although valgrind is an extremely useful program, it will not miraculously tell you about every memory bug in your program. There are several limitations that you should

C++ and dynamically typed languages

蓝咒 提交于 2019-12-08 07:21:36
问题 Today I talked to a friend about the differences between statically and dynamically typed languages (more info about the difference between static and dynamic typed languages in this SO question). After that, I was wondering what kind of trick can be used in C++ to emulate such dynamic behavior. In C++, as in other statically typed languages, the variable type is specified at compile time. For example, let's say I have to read from a file a big amount of numbers, which are in the majority of

Valgrind output with address and question marks?

五迷三道 提交于 2019-12-08 03:18:56
问题 I have just receive an output from valgrind that I do not quite understand: ==20290== Invalid read of size 1 ==20290== at 0x8C1D678: ??? ==20290== by 0x5D74C47: ??? ==20290== Address 0xee818c7d is not stack'd, malloc'd or (recently) free'd ==20290== ==20290== ==20290== Process terminating with default action of signal 11 (SIGSEGV) ==20290== Access not within mapped region at address 0xEE818C7D ==20290== at 0x8C1D678: ??? ==20290== by 0x5D74C47: ??? ==20290== If you believe this happened as a

Memory leak when setting global locale

给你一囗甜甜゛ 提交于 2019-12-08 02:34:12
问题 I am using this code to set my locale: locale::global(locale("pt_BR.UTF-8")); Am I doing this correctly ? When I run the code with Valgrind , it is displaying memory leak. How should I handle with ? Should I reset the old locale ? 376 bytes in 1 blocks are still reachable in loss record 65 of 73 ==7536== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==7536== by 0x5380664: duplocale (duplocale.c:53) ==7536== by 0x4EA436F: std::ctype<wchar_t>::ctype(__locale

Getting a valgrind for android. Problems with `valgrind`'s looking for `memcheck-arm-linux`

跟風遠走 提交于 2019-12-07 17:12:08
问题 Context is developing an android app that uses several static executable binaries through sh syscall. One of the binaries eventually segfaults when using a samsung galaxy s4 cellphone (but not when using emulator or a Sony Xperia tipo cellphone), so following http://embetek.blogspot.com.es/2011/10/valgrind-for-arm.html with several custom modifications (CFLAGS='-static -march=armv7-a') end up getting a $ ldd valgrind not a dynamic executable $ file valgrind valgrind: ELF 32-bit LSB executable