Tuesday, July 29, 2008

glibc detected double free or corruption

While segmentation fault is the most common error that C/C++ face another one that has been harassing me for some time is as follows ::

glibc detected double free or corruption


This occurs when one tries to release memory that has already been deallocated. One quick and dirty way to get rid of it is as follows :

$export MALLOC_CHECK_=0

( thats a zero at the right side of the equal to sign )

and now run the executable, it should run without a problem.

However I am not too sure if this will cause unreliable results or any other sort of problems later. I guess its best to check the code to find out and remedy the error causing this.

Could the following be of any use ?
http://valgrind.org/

See this page to understand how valgrind can help you.

No comments: