检测堆栈损坏
有时,我的应用程序中的某些代码部分会损坏堆栈。但问题在一段时间后才会显现出来。所以我们无法确定问题的具体位置。是否有任何工具可以在堆栈损坏后立即检测 C++ 应用程序中的堆栈损坏?
有没有windbg工具可以识别这个?
Sometimes some code portion in my application corrupts the stack. But the problem will be visible only after some time. So we cannot identify the exact location of the problem. Is there any tools available to detect stack corruption in a c++ application immediately after corrupting the stack?
Is there any windbg tools to identify this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
/RTCs
进行编译,从而启用堆栈帧运行时错误检查。请参阅/RTC(运行时错误检查)。Compile with
/RTCs
, which enables stack frame run-time error checking. See /RTC (Run-Time Error Checks).腐败总是发生在同一个地方吗?如果是这样,您可以轻松地使用调试器设置一个观察点来检测该位置的写入并查看谁在进行损坏。有时,分析损坏堆栈的数据也可以帮助您 - 例如,如果它是一个字符串,您可能能够缩小编写它的代码范围。
Does the corruption always happen in the same place? If so, you can easily use your debugger to set a watchpoint to detect writes at that location and see who's doing the corruption. Sometimes analyzing the data that corrupted the stack can also help you out - if it's a string, for example, you might be able to narrow down the code that's writing it.