-1

When I write a C program, I encountered a problem that is as follows:

malloc.c:3074: 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.

Please help me to fix it, thanks in advance!

Naveen
  • 74,600
  • 47
  • 176
  • 233
Charlie Epps
  • 3,595
  • 9
  • 33
  • 38

1 Answers1

2

It seems like the administration kept for memory allocation has been corrupted. My guess would be that you have something like a buffer overflow somewhere before this error occurs.

As the error is a result of an earlier problem (assuming I'm right), this can be a somewhat difficult problem to fix. Perhaps a tool like valgrind can help you to detect incorrect writes to memory. If you have a small program that demonstrates the problem, I would suggest adding that code to your question.

mweerden
  • 13,619
  • 5
  • 32
  • 32