Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Segmentation fault
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Overview == [[File:FreeBSD kernel panic.png|thumb|Example of human generated signal]] [[File:KDE Crash Handler screenshot.png|thumb|Segmentation fault affecting [[Krita]] in [[KDE]] desktop environment]] [[File:Windows null ptr dereference.png|thumb|A [[null pointer]] [[Dereference operator|dereference]] on [[Windows 8]]]] A segmentation fault occurs when a program attempts to access a [[computer memory|memory]] location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed (for example, attempting to write to a [[read-only memory|read-only]] location, or to overwrite part of the [[operating system]]). The term "segmentation" has various uses in computing; in the context of "segmentation fault", it refers to the address space of a ''program.''<ref>{{Cite web|title=Debugging Segmentation Faults and Pointer Problems - Cprogramming.com|url=https://www.cprogramming.com/debugging/segfaults.html|access-date=2021-02-03|website=www.cprogramming.com}}</ref> With memory protection, only the program's own address space is readable, and of this, only the [[call stack|stack]] and the read/write portion of the [[data segment]] of a program are writable, while read-only data allocated in the const segment and the [[code segment]] are not writable. Thus attempting to read outside of the program's address space, or writing to a read-only segment of the address space, results in a segmentation fault, hence the name. On systems using hardware [[memory segmentation]] to provide [[virtual memory]], a segmentation fault occurs when the hardware detects an attempt to refer to a non-existent segment, or to refer to a location outside the bounds of a segment, or to refer to a location in a fashion not allowed by the permissions granted for that segment. On systems using only [[paging]], an [[invalid page fault]] generally leads to a segmentation fault, and segmentation faults and page faults are both faults raised by the [[virtual memory]] management system. Segmentation faults can also occur independently of page faults: illegal access to a valid page is a segmentation fault, but not an invalid page fault, and segmentation faults can occur in the middle of a page (hence no page fault), for example in a [[buffer overflow]] that stays within a page but illegally overwrites memory. At the hardware level, the fault is initially raised by the [[memory management unit]] (MMU) on illegal access (if the referenced memory exists), as part of its memory protection feature, or an invalid page fault (if the referenced memory does not exist). If the problem is not an invalid logical address but instead an invalid physical address, a [[bus error]] is raised instead, though these are not always distinguished. At the operating system level, this fault is caught and a signal is passed on to the offending process, activating the process's handler for that signal. Different operating systems have different signal names to indicate that a segmentation fault has occurred. On [[Unix-like]] operating systems, a signal called SIGSEGV (abbreviated from ''segmentation violation'') is sent to the offending process. On [[Microsoft Windows]], the offending process receives a STATUS_ACCESS_VIOLATION [[exception handling|exception]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)