Hi. I've been reading about various signal errors, and heap corruptions. I'd like to know what the various types of heap corruptions are (like I've seen detected double free mentioned), and if there are any good sources for learning these. In addition, in the case of a SIGABRT or other heap corruption, how could we detect its type to aid in debugging? Thank you!
These are some of the common reasons for heap corruption:
. attempt to free memory that was already freed.
. attempt to free memory using a pointer that was not returned by an allocation function.
. attempt to access (read or write) memory that was freed earlier.
. attempt to write to memory using an uninitialized pointer
. attempt to access elements which are out of the bounds of a dynamically allocated array
> how could we detect its type to aid in debugging?
Let the standard library handle memory; std::vector<>, std::string etc. know how to manage memory correctly. This would eliminate most of the errors.