|
From: Christopher C. <cc...@ws...> - 2004-04-03 07:28:42
|
Hi,
I'm relatively new to Valgrind, but I'm particularly interested in using the
cachegrind skin to analyze a custom dynamic memory allocation library of
mine. Does Valgrind support the use of functions like brk() and sbrk()
within it? The documentation lead me to believe it does, but I'm getting seg
faults.
The problem only occurs after a certain amount of allocation and only when the
allocated memory is written to. I've managed to reproduce the problem with
the following simple code snippet (which I run like this: "valgrind ./test").
---
#define MAX 3000
int main () {
char* ptr;
int i;
for (i=0; i<MAX; i++) {
printf ("%d\n", i);
ptr = sbrk(1);
if (ptr == -1) {
printf ("Whoops.\n");
return 0;
}
*ptr = 0;
}
return 0;
}
---
The program works fine out of valgrind. Inside valgrind it chugs right along
until iteration number 2488 when it seg faults. Any insight into this
problem? Am I just doing something unsupported?
Oh, and I'm running valgrind-2.1.1 on Debian unstable.
Thanks for your help,
Topher Cyll
|
|
From: Nicholas N. <nj...@ca...> - 2004-04-05 09:44:39
|
On Sat, 3 Apr 2004, Christopher Cyll wrote: > I'm relatively new to Valgrind, but I'm particularly interested in using the > cachegrind skin to analyze a custom dynamic memory allocation library of > mine. Does Valgrind support the use of functions like brk() and sbrk() > within it? The documentation lead me to believe it does, but I'm getting seg > faults. It should, your problem definitely looks like a Valgrind bug. Can you please file a bug report? (valgrind.kde.org/bugs.html) thanks N |