Why do I get a SIGABRT here?

你离开我真会死。 提交于 2019-12-04 23:02:18

When you call fclose(), glibc releases some dynamically allocated structures; internally there is a free() call. malloc() and free() rely on rather complex, dynamically built structures. Apparently, glibc found that the structures were in an incoherent state, to the point that safe memory release cannot be done. glibc decided that the problem was serious enough to warrant an immediate abort.

This means that you have a bug somewhere in your code, possibly quite far from the snippet you show, a buffer overflow or a similar out-of-place memory write which damages the memory allocation structures.

You may want to try Valgrind or Electric Fence to sort such problems out.

I don't know if it's causing your particular problem, but you should always check the FILE * pointer returned by fopen() in case it's NULL.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!