关注
A segmentation fault (often shortened to SIGSEGV) is a particular error condition that can occur during the operation of computer software. A segmentation fault occurs when a program attempts to access a 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 location, or to overwrite part of the operating system). Segmentation is one approach to memory management and protection in the operating system. It has been superseded by paging for most purposes, but much of the terminology of segmentation is still used, "segmentation fault" being an example. Some operating systems still have segmentation at some logical level although paging is used as the main memory management policy. On Unix-like operating systems, a process that accesses an invalid memory address receives the SIGSEGV signal. On Microsoft Windows, a process that accesses invalid memory receives the STATUS_ACCESS_VIOLATION exception. 就是:所谓的段错误就是指访问的内存超出了系统所给这个程序的内存空间,通常这个值是由gdtr来保存的,他是一个48位的寄存器,其中的32位是保存由它指向的gdt表,后13位保存相应于gdt的下标,最后3位包括了程序是否在内存中以及程序的在cpu中的运行级别,指向的gdt是由以64位为一个单位的表,在这张表中就保存着程序运行的代码段以及数据段的起始地址以及与此相应的段限和页面交换还有程序运行级别还有内存粒度等等的信息。一旦一个程序发生了越界访问,cpu就会产生相应的异常保护,于是segmentation fault就出现了。 即“当程序试图访问不被允许访问的内存区域(比如,尝试写一块属于操作系统的内存),或以错误的类型访问内存区域(比如,尝试写一块只读内存)。这个描述是准确的。为了加深理解,我们再更加详细的概括一下SIGSEGV。段错误应该就是访问了不可访问的内存,这个内存区要么是不存在的,要么是受到系统保护的。
查看原帖
点赞 评论
相关推荐
07-01 18:00
北京交通大学 机械工程师 点赞 评论 收藏
分享
06-09 08:44
河北金融学院 golang 点赞 评论 收藏
分享
06-13 16:57
韶关学院 大数据开发工程师 点赞 评论 收藏
分享
牛客热帖
更多
正在热议
更多
# 你觉得实习能学到东西吗 #
35648次浏览 709人参与
# 百度工作体验 #
222971次浏览 1970人参与
# 现代汽车前瞻技术研发急速编程挑战赛 #
27697次浏览 216人参与
# 秋招什么时候开投比较合适? #
23004次浏览 312人参与
# 机械人与华为的爱恨情仇 #
116998次浏览 946人参与
# 实习,不懂就问 #
45862次浏览 687人参与
# 发工资后,你做的第一件事是什么 #
68091次浏览 229人参与
# 机械人集合!你是什么工程师? #
15738次浏览 89人参与
# 找不到好工作选择GAP真的丢人吗 #
78161次浏览 938人参与
# 我想去国央企的原因 #
59895次浏览 393人参与
# 如何准备秋招 #
20171次浏览 386人参与
# 工作中哪个瞬间让你想离职 #
25822次浏览 177人参与
# 入职第四天,心情怎么样 #
29376次浏览 417人参与
# 拼多多工作体验 #
28475次浏览 197人参与
# 多益网络求职进展汇总 #
29155次浏览 134人参与
# 快手求职进展汇总 #
546943次浏览 6001人参与
# 硬件应届生薪资是否普遍偏低? #
74012次浏览 514人参与
# 不考虑转正,实习多久合适 #
32191次浏览 145人参与
# 面试中,你被问过哪些奇葩问题? #
68481次浏览 796人参与
# 你们公司几号发工资 #
21075次浏览 140人参与
# 如果再来一次,你还会学硬件吗 #
125666次浏览 1402人参与