Sunday, December 18, 2011

Segmentation fault causes and solution

Well, this "SEGMENTATION FAULT" error encountered me and my friends while doing network programming in C on a Linux platform.

Cause for this error : A segmentation fault occurs mainly when our code tries to access some memory location which it is not suppose to access.

For example :
  1. Working on a dangling pointer.
  2. Writing past the allocated area on heap.
  3. Operating on an array without boundary checks.
  4. Freeing a memory twice.
  5. Working on Returned address of a local variable
  6. Running out of memory(stack or heap)
So, avoid / debug above errors to get rid of this

[via]If you enjoyed this post, make sure you subscribe to my RSS feed! Comments are encouraged

No comments:
Write comments