段错误就是指访问的内存超出了系统所给这个程序的内存空间,通常这个值是由gd tr来保存的,他是一个48位的寄存器,其中的32位是保存由它指向的 gdt表,后13位保存 相应于gdt的下标,最后3位包括了程序是否在内存中以及程序的在cpu中的运行级别,指向 的gdt是由以64位为一个单位的表,在这张表中就保存着程序运行的代码段以及数据段的起 始地址以及与此相应的段限和页面交换还有程序运行级别还有内存粒度等等的信息。
如果是在操纵指针的话,就可能产生段错误。
If we were manipulating Pointers we'd probably end up with a segfault.
清单11所示程序是一个段错误的典型例子。
The sample program here is a typical example of a segmentation fault.
举例来说,对于段错误,您需要了解段错误发生在代码的哪一行。
For example, with segmentation faults, you need to know on which line of code the seg fault occurred.
I've read through the same thing twenty times and I've missed something obvious. Someone who's never seen it before looks at and says, did you really mean to do this?
但是它们有一双旁观者之眼,我把同一段代码读上20遍,都会漏掉一些很明显的错误,从没看过这段代码的人会告诉我?
foo You probably weren't calling foo ad nauseam here but segmentation fault refers to segments of memory colliding.
你可能不会倒胃口地调用,但是段错误是涉及内存段冲突。
Segfault. And why might I possibly have done that?
段错误,为什么可能出现这种情况呢?
应用推荐