tags:

views:

1913

answers:

2

Hi, 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!

+2  A: 

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
thank you all the same.
Charlie Epps
My program is a little large, I can't display all the codes here.
Charlie Epps
A: 

haha, thank for mweerden's help. he tell me a good tool valgrind, and it works well on my problem. Thans very much.

Charlie Epps