The line of code described has accessed a memory block outside of the allocated space for the program. Check if you have accidently called outside the range of an array or something similar. As shown below, the space you may be trying to access is outside the space allocated for the program.
-------------------------- | | | | | allocated space | | | | | |------------------------| | | | | <------ address trying to get | | | unallocated space | | | | | | | | | | | | | --------------------------
The value of the pointer is not considered a valid address for a pointer to point to. Check if you have accidently dereferenced something not considered to be a pointer or is a pointer pointing to an invalid space.
The value of the pointer is not considered to be initialized and is declared only. Check if you did not give a value to the pointer you are dereferencing.
The block you have tried to free is considered to be null. Check if the pointer has not been assigned yet or has changed to null before it was freed.
The block of memory the pointer points to is considered to already be freed. Check if you have called free twice on the same pointer. If not, check if you have freed another pointer with the same value as that pointer.
The pointer you have tried to call free on is no longer a valid address to point to. Similarly to dereferencing a non-pointer, check if the pointer is changed to something not considered to be a pointer or a pointer that points to and invalid space. This can also appear when using arithmetic on pointers and assigning that value to the pointer as it would not be in the beginning of the block.
The block that you have tried to change in the pointer is considered to be immutable. This is most usually the result of changing a pointer to an immutable string. Check if the block of address your pointer is pointing to is not immutable; this includes malloc'ing but switching the pointer to point to an immutable string.
The block that you have tried to change is already freed. Check if the pointer you have used was changed or if you had already freed that block of memory beforehand.
The block that you have tried to dereference/read is not valid. This is different from dereferencing an uninitialized pointer as there is malloc'd space, but the space is not initialized yet. Check if you have changed anything in the block or, if you want it to be initialized beforehand, use calloc.
The program you have called has exhausted the stack and there is no more space. This is usually a problem with recursive functions. Check if you have a recursive function that could possibly not terminate.