I am trying to use memprof-0.5.1(because apt-get memprof gives me this
version, although I know version 0.6 came out recently) to debug my
program. My Linux box is a ubuntu, here I list its
kernel/glibc/linker/compiler info
--------------------------------------------------
uname -a
=Linux 2.6.16.27-gg1-em64t #1 SMP
getconf GNU_GLIBC_VERSION
=>glibc 2.3.5
ld --version
=>GNU ld version 2.16.1 Debian GNU/Linux
Copyright 2005 Free Software Foundation, Inc
gcc --version
=>gcc (GCC) 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)
memprof --version
=>memprof 0.5.1
--------------------------------------------------
When I test this following simple case by
#gcc -o mytest -g main.c
#memprof mytest
The system hang there when I select File->Run Program->(select mytest),
and also an error message popped up in the console:
*** glibc detected *** free(): invalid pointer: 0x4e401580 ***
-----------------main.c------------------------
#include <stdlib.h>
#include <stdio.h>
void foo(){
int i = 0, j = 8, k = 0;
for(i = 0 ; i < 20; i ++){
malloc(100);
k = j;
while(j < 2*k){
j++;
}
j = 2*k;
printf("k = %d\n", k);
}
}
int main(){
int i = 0, j =2;
for(i = 0; i < 10; i++){
j = j * 2;
foo();
}
}
----------end of main.c -----------------