C/Core Dump
Expert: Zlatko - 9/28/2011
QuestionHi,
This is Lakshmipathy. I am facing segmentation fault one of C++ library. When i have tried to debug the code using gdb, got following backtrace information. The library crashed exactly at memalign_check api. Could you please explain why segmentation fault occured and what is the cause of issue?
#0 0x006c4bea in memalign_check () from /lib/tls/libc.so.6
#1 0x006c6001 in malloc_get_state () from /lib/tls/libc.so.6
#2 0xf7fd45ae in ?? ()
#3 0x00000401 in ?? ()
#4 0x00000000 in ?? ()
Lakshmipathy
AnswerHello Lakshmipathy
It is impossible to know the reason for the core dump without seeing the code. Core dumps often occur because you are accessing memory which is not available to you. For example, you may be accessing memory which has been freed, or you may have written past the end of allocated memory. If your code is short enough, you can post it as a follow up question.
You could try disabling all your free function calls, and if the problem goes away, it means you have been accessing freed memory. You could place print statements into your program to help determine where it crashes, since your stack trace shows very little. That may help, although sometimes programs crash long after the actual cause. You could try to increase the size of your memory allocations, and if the problem goes away it means you were writing past the allocated bounds.
Memory problems are one of the hardest to debug. Good luck.
Best regards
Zlatko