What could be the possible reasons for segmentation fault?

Why is a segmentation fault called a segmentation fault?

  • I understand that a segfault is an access violation to memory that the CPU cannot physically address, but why is it called a "segmentation" fault.

  • Answer:

    Segmentation is a virtual memory management technique similar to paging.  Memory is divided into "segments" (which, unlike pages, can be different sizes).  Programs may be restricted to reading or writing memory within their own segments.  A miscalculated address might lead your program to read or write outside its allocated segment, triggering an interrupt.  (That's probably somewhat oversimplified, but it gets at the main point.)

Matthew Saltzman at Quora Visit the source

Was this solution helpful to you?

Other answers

That is old terminology from the days when memory management was done through many variable length segments instead of the current fad of having just a few areas for code and stack and data.   In the old days a good compiler and run-time could put each array and object each in a hardware-protected segment so that buffer overflows were impossible.  Those were the days.

George Gonzalez

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.