glibc error

Hi All,

This is my first time posting on this forum. I'd like to
participate actively on this list.

Here we go!

I'm making a little application and I'm using ncurses. After a while
using it, I receive the following error and the stack trace is shown:

glibc detected malloc() : memory corruption

Anybody knows when glibc throws this error??

I'll appreciate your help!

Thanks in advance!

malloc is complaining that you have corrupted a pointer in some way example:

char *ptr=malloc(100);
char tmp[10={0x0};
..........
.......
ptr++;
............
..........
free(ptr);

The error happens on a realloc or a free because the pointer no longer references the same start of memory. You can get the same result by writing, say, 15 characters into the tmp string, so that you overwrote the string and changed the memory value stored in ptr.

Hi jim,

Thanks a lot for your answer, I'll re-check my code in order to find when malloc is trying to free up an incorrect memory address.
If I can't find the error, I'll post my code, because the error is thrown by a function of ncurses library. I think I'm passing a bad argument to this function.

Thank again!

try add -Wall to your compile statement

Thanks frank, but I already have the -Wall flag in the Makefile.
Thaks!

There is also electric fence which can find buffer overruns for you.

I've never used that kind of tool, but I'll try to use it in my application in order to find out what's happening.

Thanks!