Possible Duplicate:
malloc.c:3074 error?
I am getting this strange error on execution of my C++ code:
malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
Aborted
The program runs fine upto a point where it catches the above Segmentation fault(SIGSEGV) from an already executed line. I found out this using gdb.
Something has corrupted the heap by writing to an invalid memory location. The most likely causes are writing outside the bounds of an allocated object, or writing to an object after it has been deleted.
These errors can be difficult to track down with a debugger. The best tool is a memory checker, such as valgrind.