valgrind

Watch a memory range in gdb?

匿名 (未验证) 提交于 2019-12-03 01:52:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am debugging a program in gdb and I want the program to stop when the memory region 0x08049000 to 0x0804a000 is accessed. When I try to set memory breakpoints manually, gdb does not seem to support more than two locations at a time. (gdb) awatch *0x08049000 Hardware access (read/write) watchpoint 1: *0x08049000 (gdb) awatch *0x08049001 Hardware access (read/write) watchpoint 2: *0x08049001 (gdb) awatch *0x08049002 Hardware access (read/write) watchpoint 3: *0x08049002 (gdb) run Starting program: /home/iblue/git/some-code/some-executable

Are there known false positives issues with Valgrind?

不想你离开。 提交于 2019-12-03 01:37:41
Are there any known false positives with Valgrind? I get a 'Conditional jump or move depends on uninitialised value(s)' with the fmemopen function, writing in C and compiling with GCC. Can I be sure it's real? EDIT: Are there known issues that are not in the suppression files? Are there some things one can do in a program, that are not really errors but Valgrind will say they are? If there are known issues, a list would be nice. Yes, there are false positives with Valgrind, that's why it has suppression files for particular glibc and gcc versions, for example. The false positives may arise if

How to Learn C Debugging and Best Practices [closed]

大憨熊 提交于 2019-12-03 01:33:09
Closed . This question needs to be more focused. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it focuses on one problem only by editing this post . I've written an Apache module in C. Under certain conditions, I can get it to segfault, but I have no idea as to why. At this point, it could be my code, it could be the way I'm compiling the program, or it could be a bug in the OS library (the segfault happens during a call to dlopen()). I've tried running through GDB and Valgrind with no success. GDB gives me a backtrace into the dlopen

Valgrind: Memory still reachable with trivial program using <iostream>

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Take the following trivial program: #include int main () { return 0 ; } If I run this using valgrind, I'm told that there are 72,704 bytes in 1 blocks that are still reachable . There have been extensive discussions on SO about whether or not to worry about still reachable warnings--I'm not concerned about that. I'd just like to understand how simply including a standard library header could cause a still reachable warning, when none of the objects from that library were allocated in the program itself. Here is the full valgrind

Memory leak checking on Windows with QT and MinGW32

匿名 (未验证) 提交于 2019-12-03 01:32:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Lately I have been developing in C++ with QT Creator. All is well and I'm nearly at the point of packaging and distributing my application. But obviously before any release you better make sure you have everything right. So I'm at the testing stage, and something tells me that I have some slight memory issues. Nothing serious, but I like to obsess over these ;-). So I decided to try some memory leak detection libraries. For starters I looked at this question. I disregarded Purify and Insure++ because of the costs. Someone else suggested to

Valgrind reports errors for a very simple C program

匿名 (未验证) 提交于 2019-12-03 01:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm learning C language from Learn C The Hard Way . I'm on exercise 6 and while I can make it work, valgrind repots a lot of errors. Here's the stripped down minimal program from a file ex6.c : #include int main(int argc, char *argv[]) { char initial = 'A'; float power = 2.345f; printf("Character is %c.\n", initial); printf("You have %f levels of power.\n", power); return 0; } Content of Makefile is just CFLAGS=-Wall -g . I compile the program with $ make ex6 (there are no compiler warnings or errors). Executing with $ ./ex6 produces the

Yosemite and Valgrind

匿名 (未验证) 提交于 2019-12-03 01:27:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Can you tell me how to install valgrind on yosemite? When I try to install it i get " checking for the kernel version... unsupported (14.0.0) configure: error: Valgrind works on Darwin 10.x, 11.x, 12.x and 13.x (Mac OS X 10.6/7/8/9) " There is no official path or update, and I didn't found anything (except http://comments.gmane.org/gmane.comp.kde.devel.bugs/1553705 , but they didn't resolve that problem). 回答1: As there's no stable release that supports Yosemite, you can install the latest development version with brew install --HEAD valgrind

Memory leak in basic stack

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm working on a real simple stack implementation, and I can't seem to figure out why I have a memory leak. What I expect from the code is that 5 nodes are allocated in push() and 5 nodes are freed in displayAndDestroy(). But Valgrind says I've allocated 6 nodes worth of data and only freed 5. I've been staring at this for a while and I'm not exactly sure where I went wrong. #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct STACK{ char data[100]; struct STACK *next; } stack; stack *push( stack *oldTop, char *data ) {

Valgrind reporting a segment overflow

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When running my program with valgrind / callgrind I get the following message a lot: ==21734== brk segment overflow in thread #1: can't grow to 0x4a39000 (with different addresses) Note that it is not preceded by a stack overflow message. I can't find any documentation on this message and I have no idea what is overflowing exactly. Can anybody help me figure out what the problem is? Is this a problem of valgrind, or of my program? 回答1: Line 1327 from the valgrind source code points to the user manual, "see section Limitations in user manual"

C strings, strlen and Valgrind

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to understand why Valgrind is spitting out : ==3409== Invalid read of size 8 ==3409== at 0x4EA3B92: __GI_strlen (strlen.S:31) whenever I'm applying strlen on a dynamically allocated string? Here is a short testcase : #include #include #include int main() { char *hello = "Hello World"; char *hello2; /* Step 1 */ printf("Step 1\n"); printf("strlen : %lu\n",(unsigned long)strlen(hello)); /* Step 2 */ hello2 = calloc(12,sizeof(char)); hello2[0] = 'H'; hello2[1] = 'e'; hello2[2] = 'l'; hello2[3] = 'l'; hello2[4] = 'o'; hello2[5] = ' ';