开发者

weird SIGABORT on malloc/calloc call

running my program with gdb I get this:

fem.o: 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.

Program received signal SIGABRT, Aborted. 0xb7fe1424 in __kernel_vsyscall ()

I found that this error arises afte开发者_StackOverflow中文版r this code:

problem->y0 = (double *)calloc(n_tot, sizeof(double));

problem is a structure which has double *y0 as member.

Previously in the function, I do this

problem = (fem_problem *)calloc(1, sizeof(fem_problem));

and I don't get any error neither problem == NULL.

some suggestion?

ADD:

I already checked the content of n_tot, it has the right number


The assertion is telling you that the heap internal data structures are corrupt, probably due to your writing outside the bounds of an allocated block at some point. Try running with valgrind to see if it can tell you where you're going wrong.


There could be any number of problems, for example:

  • The value of n_tot could be garbage.

  • You have written outside of an allocated block, and in doing so you have destroyed data structures used to maintain the heap.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜