什么是分段错误和堆栈溢出的区别? [英] What is the difference between a segmentation fault and a stack overflow?

查看:202
本文介绍了什么是分段错误和堆栈溢出的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,当我们称说,递归功能,连续调用被存储在堆栈中。然而,由于一个错误,如果它继续无限的错误是分段错(如看到GCC)。

For example when we call say, a recursive function, the successive calls are stored in the stack. However, due to an error if it goes on infinitely the error is 'Segmentation fault' (as seen on GCC).

难道不应该一直堆栈溢出?那么,什么是两者之间的基本区别?

Shouldn't it have been 'stack-overflow'? What then is the basic difference between the two?

顺便说一句,一个解释是不是维基百科链接(通过该走了,但没有回答具体查询)更有帮助。

Btw, an explanation would be more helpful than wikipedia links (gone through that, but no answer to specific query).

推荐答案

堆栈溢出是[A]的原因,段错误是结果。

Stack overflow is [a] cause, segmentation fault is the result.

至少在x86和ARM的栈是把局部变量和返回函数调用地址保留的一块内存。当堆栈耗尽时,保留区的外部的存储器将被存取。但应用程序并没有让内核为这个内存,从而段错误将存储器保护产生。

At least on x86 and ARM, the "stack" is a piece of memory reserved for placing local variables and return addresses of function calls. When the stack is exhausted, the memory outside of the reserved area will be accessed. But the app did not ask the kernel for this memory, thus a SegFault will be generated for memory protection.

这篇关于什么是分段错误和堆栈溢出的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆