Segmentation fault /段错误
时间:2006-06-26 10:04:37 来源:本站搜集整理 作者:Eric
Linux编程常出现的 Segmentation fault /段错误
One of the most common problems when making software is errors like "Segmentation fault", also called SegFault. Here is what a SegFault is. Virtual memory in a computer can be created in 2 ways: pages or segments. Paging means that the memory is divided in pages of equal size, containing words of memory in it. Segmentation means that every process has a segment of memory of needed size, with gaps of empty memory blocks between the segments. The operating system knows the upper limit of every segment, and every segment begins at a virtual address 0. When a program accesses a memory block, it calls a virtual address that the Memory Management Unit (MMU) maps to a real address. If the operating system sees that the requested address doesn't match any valid address in the segment, it will send a signal to the process terminating it. SegFaults are the direct result of a memory error. The program has a bad pointer, a memory leak or any kind of error that makes it access the wrong memory address. To correct these errors you need to check pointers and arrays for errors.
作者Blog:http://blog.csdn.net/daculas/
通常的原因就是遇到了内存地址非法访问
One of the most common problems when making software is errors like "Segmentation fault", also called SegFault. Here is what a SegFault is. Virtual memory in a computer can be created in 2 ways: pages or segments. Paging means that the memory is divided in pages of equal size, containing words of memory in it. Segmentation means that every process has a segment of memory of needed size, with gaps of empty memory blocks between the segments. The operating system knows the upper limit of every segment, and every segment begins at a virtual address 0. When a program accesses a memory block, it calls a virtual address that the Memory Management Unit (MMU) maps to a real address. If the operating system sees that the requested address doesn't match any valid address in the segment, it will send a signal to the process terminating it. SegFaults are the direct result of a memory error. The program has a bad pointer, a memory leak or any kind of error that makes it access the wrong memory address. To correct these errors you need to check pointers and arrays for errors.
作者Blog:http://blog.csdn.net/daculas/
通常的原因就是遇到了内存地址非法访问
文章评论
共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面