由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - dereference a NULL pointer in C
相关主题
请教两道linux面试题目socket被block在accept的时候不能close……
C++ Q87: What is wrong with this swap function? (转载)一个c语言的问题
如何区分read page fault 和 write page fault[合集] C++,一个函数完成后出segmentaion fault
c ptr questionconst char *p, is it ok to change p[1] ?
Segmentation faultC++ Segment Fault
关于valgrind 的一个问题A weird segmentation fault!
Strange problem with CGI (转载)谁知道这个问题的答案 (转载)
问个C++ Segmentation Fault的问题Java 问题,请教如何找出一个array里的duplicate segments?
相关话题的讨论汇总
话题: null话题: pointer话题: fault
进入Programming版参与讨论
1 (共1页)
P***t
发帖数: 165
1
产生segmentation fault的具体过程是怎样的?
比如是在OS发现要访问virutal memory address为0就报seg fault,
还是会进行到访问页表获取到physical memory address并访问才会报?
p**********g
发帖数: 9558
2
Linux的gdt表的第一项就是给这个准备的
从书里抄了这么一段
The first entry of the GDT is always set to 0. This ensures the logic
address with a null Segment Selector will be considered invalid, thus
causing a processor exception.
呵呵,要不怎么叫segmentation fault呢
p**********g
发帖数: 9558
3
至于说linux怎么handle这个exception,就是另外一个topic了
t****t
发帖数: 6806
4
目前几乎所有的32位OS在应用级都是flat memory model, 不怎么用段寄存器的. 所有
的段都是base 0, size=4G.
所以0指针是DS:0, 不是0:0, 跟GDT第一项没关系.

【在 p**********g 的大作中提到】
: Linux的gdt表的第一项就是给这个准备的
: 从书里抄了这么一段
: The first entry of the GDT is always set to 0. This ensures the logic
: address with a null Segment Selector will be considered invalid, thus
: causing a processor exception.
: 呵呵,要不怎么叫segmentation fault呢

p**********g
发帖数: 9558
5
"segmentation fault"是说段错误,说和段映射没有关系似乎说不过去?不过段映射一
般是intel上的。
应用根本看不到内存管理的映射(segment or paging),不过确实有很多不用段映射的
,比如arm,不过没有具体看过linux在arm上的实现以及这个"segmentation fault"
我找找看
D*******a
发帖数: 3688
6
this is about null segment selector, not null pointer.
segmentation fault is generally caused by accessing non-existant memory or
denied access.

【在 p**********g 的大作中提到】
: Linux的gdt表的第一项就是给这个准备的
: 从书里抄了这么一段
: The first entry of the GDT is always set to 0. This ensures the logic
: address with a null Segment Selector will be considered invalid, thus
: causing a processor exception.
: 呵呵,要不怎么叫segmentation fault呢

p**********g
发帖数: 9558
7
是我搞错了

【在 D*******a 的大作中提到】
: this is about null segment selector, not null pointer.
: segmentation fault is generally caused by accessing non-existant memory or
: denied access.

m*****e
发帖数: 4193
8
If you really want to know how Linux virtual memory management works, dive
into copy-on-write.
Last time I looked into it, I found a bug. :-)

【在 p**********g 的大作中提到】
: "segmentation fault"是说段错误,说和段映射没有关系似乎说不过去?不过段映射一
: 般是intel上的。
: 应用根本看不到内存管理的映射(segment or paging),不过确实有很多不用段映射的
: ,比如arm,不过没有具体看过linux在arm上的实现以及这个"segmentation fault"
: 我找找看

z***e
发帖数: 5393
9
现在到底还有没有segment的概念啊?我看到OS里面介绍也是说某段区域给user mode,
某段区域给别的什么什么,但是看起来都是在连续空间分配。
一直不明白386/486时期那个segment到底是什么意思。

【在 t****t 的大作中提到】
: 目前几乎所有的32位OS在应用级都是flat memory model, 不怎么用段寄存器的. 所有
: 的段都是base 0, size=4G.
: 所以0指针是DS:0, 不是0:0, 跟GDT第一项没关系.

T*****9
发帖数: 2484
10
vma 为0的时候是page fault
然后系统试图load page,如果load fail, 就会报seg fault

【在 P***t 的大作中提到】
: 产生segmentation fault的具体过程是怎样的?
: 比如是在OS发现要访问virutal memory address为0就报seg fault,
: 还是会进行到访问页表获取到physical memory address并访问才会报?

1 (共1页)
进入Programming版参与讨论
相关主题
Java 问题,请教如何找出一个array里的duplicate segments?Segmentation fault
C一个问题搞不懂关于valgrind 的一个问题
一个简单的小问题Strange problem with CGI (转载)
C++ Q05: pointer to constant variable问个C++ Segmentation Fault的问题
请教两道linux面试题目socket被block在accept的时候不能close……
C++ Q87: What is wrong with this swap function? (转载)一个c语言的问题
如何区分read page fault 和 write page fault[合集] C++,一个函数完成后出segmentaion fault
c ptr questionconst char *p, is it ok to change p[1] ?
相关话题的讨论汇总
话题: null话题: pointer话题: fault