*** glibc detected *** ./a.out: free(): corrupted unsorted chunks: 0x00000000007646b0 ***
*** glibc detected *** ./a.out: malloc(): memory corruption: 0x00000000007635a0 ***
I'm getting the above error. But I'm sure that I'm not using the memory after freeing. Why do I get the above error ?
All heaps, store certain kinds of meta-data inside itself. When you do a malloc or free, the heap will often perform some book-keeping functions on the heap. If it detects something totally unexpected in the meta-data, it will normally crash.
Normal heap operations are highly unlikely to cause such problems, so your program is most likely to be the cause. Since your program has access to all the memory in the process including the heap meta-data, your program could have accidentally overwritten some of the meta-data.
A likely cause is writing beyond the end of an allocated buffer. This write will most probably be allowed and is extremely likely to corrupt the heap meta-data. When this detected by the heap, your program will normally abort.
It could be that you are trying to free with a pointer that does not correctly point to dynamically alocated memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With