admin管理员组文章数量:1389779
When I have finished a software, I carry out a stack overflow test at the end. Why don't I have to do this with a compiled stack?
Are overflows really completely impossible here or only very rare?
When I have finished a software, I carry out a stack overflow test at the end. Why don't I have to do this with a compiled stack?
Are overflows really completely impossible here or only very rare?
- 2 Note well that the ability to use a compiled stack is an xc8-specific feature, motivated by the characteristics of some of the devices that this compiler targets. Note also that C itself does not require that there be a stack in the conventional sense at all, though there are practical considerations that make a stack a very appealing implementation choice. – John Bollinger Commented Mar 13 at 16:02
1 Answer
Reset to default 7The XC8 "compiled stack" isn't really a stack at all, in the sense of pushing and popping. It holds the kind of data that would traditionally be allocated "on the stack" - local variables - but it doesn't grow. There's no stack pointer. Everything is just allocated at a fixed address. The "stack" can't grow past its limits if it doesn't grow in the first place.
This of course runs into other limitations not found with traditional stack allocation. For example, functions that use the compiled stack can't be called recursively. All calls to such functions have their local variables allocated at the same addresses, so if you tried to make a recursive call, it'd be stomping over the original call's local variables.
You can read more in the XC8 C Compiler User's Guide, particularly section 5.5.2.2.1, "Compiled Stack Operation".
本文标签: cIs a stack overflow on a compiled stack really impossibleStack Overflow
版权声明:本文标题:c - Is a stack overflow on a compiled stack really impossible? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744694551a2620197.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论