开发者

malloc error C++ [duplicate]

This question already has an answer here: Closed 12 years ago.

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_s开发者_StackOverflow中文版ize) >= (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.


Based on your statement that the breaking line is called previously in program's execution and runs without fail to a point: This error is prabably caused by "damaged" memory structures.

This kind of strange and inconsistent behavior can be expected if you were to allocate memory and overrun writing to the buffer or if you were to allocate memory and then use the returned address without checking it to ensure that it is a non-zero address (memory allocation failure).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜