38
  1. I was wondering what differences and relations are between segmentation fault and page fault?
    세그멘테이션 오류와 페이지 오류 사이의 차이점과 관계가 무엇인지 궁금합니다.

  2. Does segmentation fault only belong to segmented memory model?
    세그멘테이션 오류는 세그먼트 메모리 모델에만 해당되나요?

    Does page fault only belong to paged memory model?
    페이지 폴트는 페이징 메모리 모델에만 해당되나요?

    If both are yes, since most computer systems such as x86 and Linux use paged memory model instead of segmented memory model, why does GCC C compiler sometimes report segmentation fault error?
    두 질문 모두 예라면, x86과 Linux 같은 대부분의 컴퓨터 시스템이 세그먼트 메모리 모델 대신 페이징 메모리 모델을 사용하는데, 왜 GCC C 컴파일러가 가끔 세그멘테이션 폴트 오류를 보고하나요?

Thanks and regards!  감사합니다!

CC BY-SA 3.0

3 Answers 3

48

These two things are very dissimilar, actually. A segmentation fault means a program tried to access an invalid or illegal memory address: for example, 0, or a value larger than any valid pointer. A page fault is when a pointer tries to access a page of address space that's currently not mapped onto physical memory, so that the MMU needs to grab it off of disk before it can be used. The former is an illegal condition and the program will generally be aborted; the latter is perfectly normal and the program won't even know about it.
이 두 가지는 사실 매우 다릅니다. 세그멘테이션 폴트는 프로그램이 잘못되었거나 불법적인 메모리 주소에 접근하려고 했을 때 발생합니다. 예를 들어, 0이거나 유효한 포인터보다 큰 값이 이에 해당합니다. 페이지 폴트는 포인터가 현재 물리 메모리에 매핑되어 있지 않은 주소 공간의 페이지에 접근하려 할 때 발생하며, 이 경우 MMU가 디스크에서 해당 페이지를 가져와야 합니다. 전자는 불법적인 상태로 프로그램이 일반적으로 중단되지만, 후자는 정상적인 상황이며 프로그램은 이를 인지하지 못합니다.

"Segmentation" isn't at all related to the old "segmented memory model" used by early x86 processors; it's an earlier use which just refers to a portion or segment of memory.
"Segmentation"은 초기 x86 프로세서에서 사용된 오래된 "분할 메모리 모델"과 전혀 관련이 없으며, 단지 메모리의 일부 또는 구간을 의미하는 더 이전의 용어입니다.

CC BY-SA 3.0
4
  • 1
    Thanks! (1) What are there relation with segmented memory model and paged memory model? (2) what does "segmentation" in segmentation faults mean? Does it mean segment in segmented memory model? If yes, why can it still happen on paged memory model besides segmented memory model?
    감사합니다! (1) 분할 메모리 모델과 페이징 메모리 모델은 어떤 관계가 있나요? (2) 세그멘테이션 오류에서 "segmentation"은 무엇을 의미하나요? 분할 메모리 모델의 세그먼트를 의미하나요? 그렇다면 분할 메모리 모델뿐만 아니라 페이징 메모리 모델에서도 왜 이런 오류가 발생할 수 있나요?
    – Tim
    Commented Aug 5, 2011 at 1:54
  • 2
    Most page faults are not noticed by the program, but Wikipedia says that an "invalid" page fault (en.wikipedia.org/wiki/Page_fault#Invalid) could cause a segmentation fault (depending on which OS you're using).
    대부분의 페이지 폴트는 프로그램에서 인지하지 못하지만, 위키피디아에 따르면 "잘못된" 페이지 폴트(en.wikipedia.org/wiki/Page_fault#Invalid)는 (사용하는 OS에 따라) 세그멘테이션 오류를 일으킬 수 있다고 합니다.
    Commented Jul 15, 2012 at 20:48
  • 4
    When you say "page fault", your description is only covering "valid" page faults. Both start with a page-fault hardware exception, and if the OS determines that the process didn't have that page mapped, then it's invalid and delivers a SIGSEGV. But if it is valid, the page-fault handler can queue up I/O (hard page fault) or do copy-on-write or whatever lazy memory allocation (soft page fault).
    "페이지 폴트"라고 할 때, 당신의 설명은 "유효한" 페이지 폴트만을 다루고 있습니다. 두 경우 모두 페이지 폴트 하드웨어 예외로 시작하며, OS가 해당 프로세스에 그 페이지가 매핑되어 있지 않다고 판단하면, 이는 잘못된 페이지 폴트가 되어 SIGSEGV를 발생시킵니다. 하지만 유효한 경우에는 페이지 폴트 핸들러가 I/O를 대기열에 넣거나(하드 페이지 폴트), 복사-쓰기(copy-on-write) 또는 기타 지연 메모리 할당(소프트 페이지 폴트)을 수행할 수 있습니다.
    Commented Oct 12, 2020 at 9:07
  • 1
    Also, you are only describing Major faults (where disk need be consulted). Mostly you will see minor faults which happen when you reference unmapped pages in your address space and the MMU simply needs to map those page frames to physical pages (no disk needed). Segfault is a similar process except the references pages are not valid / in your address space I believe.
    또한, 당신은 디스크를 참조해야 하는 Major fault만 설명하고 있습니다. 대부분은 주소 공간에서 매핑되지 않은 페이지를 참조할 때 발생하는 minor fault를 보게 되며, 이 경우 MMU가 단순히 해당 페이지 프레임을 물리 페이지에 매핑하면 됩니다(디스크는 필요하지 않습니다). Segfault는 참조된 페이지가 유효하지 않거나 주소 공간에 없을 때 발생하는 유사한 과정이라고 생각합니다.
    – GL2014
    Commented Mar 22, 2022 at 2:11
12

Segmentation faults occur when the memory is not allowed to be accessed (does not exist, or is forbidden). Most frequently they occur when you dereference a null variable or run off the end of an array. Page faults occur when memory that is mapped but not loaded is accessed. They are not errors, and signal to the operating system that it should load the appropriate page into memory.
세그멘테이션 오류는 메모리에 접근이 허용되지 않을 때 발생합니다(존재하지 않거나 접근이 금지된 경우). 가장 흔한 경우는 널 변수 역참조나 배열의 끝을 벗어날 때입니다. 페이지 폴트는 매핑은 되어 있지만 로드되지 않은 메모리에 접근할 때 발생합니다. 이는 오류가 아니며 운영체제에 적절한 페이지를 메모리에 로드하라는 신호를 보냅니다.

CC BY-SA 4.0
2
  • Thanks! (1) What are there relation with segmented memory model and paged memory model? (2) what does "segmentation" in segmentation faults mean? Does it mean segment in segmented memory model? If yes, why can it still happen on paged memory model besides segmented memory model?
    감사합니다! (1) 세그멘티드 메모리 모델과 페이징 메모리 모델과의 관계는 무엇인가요? (2) 세그멘테이션 오류에서 "segmentation"은 무엇을 의미하나요? 세그멘티드 메모리 모델의 세그먼트를 의미하나요? 그렇다면 왜 세그멘티드 메모리 모델뿐만 아니라 페이징 메모리 모델에서도 여전히 발생할 수 있나요?
    – Tim
    Commented Aug 5, 2011 at 1:52
  • 3
    One other cause for segmentation fault: writing to a VALID memory address that resides in a memory page with page protections set to read-only or read/exec-only. For example, writing to an address in the .text (code) section will cause a SIGSEGV (but reading that same address will be safe)
    세그멘테이션 오류의 또 다른 원인: 페이지 보호가 읽기 전용 또는 읽기/실행 전용으로 설정된 메모리 페이지에 있는 유효한 메모리 주소에 쓰기 작업을 하는 경우입니다. 예를 들어, .text(코드) 섹션의 주소에 쓰기를 하면 SIGSEGV가 발생하지만, 같은 주소를 읽는 것은 안전합니다.
    – mzpq
    Commented May 24, 2017 at 3:38
0

For posterity, here's a video lecture from UC Berkeley's OS course discussing this. https://www.youtube.com/watch?v=IBgkKX6DUTM&t=3345s
기록을 위해, UC Berkeley의 운영체제 강의에서 이 내용을 다루는 동영상 강의입니다. https://www.youtube.com/watch?v=IBgkKX6DUTM&t=3345s

Tl;dr above answers (basically). But worth mentioning that the term does come from older style address translation where MMU's contained segment tables instead of page tables.
요약하자면 위 답변들과 같습니다(기본적으로). 하지만 이 용어는 페이지 테이블 대신 세그먼트 테이블을 포함하는 구식 주소 변환 방식에서 유래했다는 점을 언급할 가치가 있습니다.

CC BY-SA 4.0
2
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    현재 작성된 답변은 명확하지 않습니다. 질문에 어떻게 답변하는지 이해를 돕기 위해 추가 세부 정보를 편집하여 추가해 주세요. 좋은 답변 작성 방법에 대한 자세한 내용은 도움말 센터에서 확인할 수 있습니다.
    – Community Bot  – 봇
    Commented Jun 1, 2023 at 7:23
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    이 링크가 질문에 답할 수는 있지만, 답변의 핵심 부분을 여기에 포함시키고 참고용으로 링크를 제공하는 것이 더 좋습니다. 링크만 있는 답변은 링크된 페이지가 변경되면 무효가 될 수 있습니다. - 검토에서
    Commented Jun 6, 2023 at 12:19

Your Answer   당신의 답변

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers
답변을 얻기 위해 질문을 시작하세요

Find the answer to your question by asking.
질문을 하여 답을 찾아보세요.

Ask question

Explore related questions
관련 질문 탐색

See similar questions with these tags.
이 태그가 포함된 유사한 질문 보기.