Search code examples
csegmentation-faultheap-memoryfreecorruption

Segfault on free()


I'm having a simple problem: my program segfaults when freeing some memory allocated using calloc(). The last function in the backtrace is _IO_str_pbackfail. Currently I'm using icc version 12.1.6. According to other questions on stack overflow, this I usually caused by heap corruption. By looking at calloc sources, it seems that the function writes some data in the first 16 bytes of the allocated space. I've tried to add a watchpoint on these bytes but the debugger isn't detecting any malicious write. Any ideas on how to track down this issue?


Solution

  • You could try running with MALLOC_CHECK_=2 or valgrind.