我如何保证在Visual Studio 2005中捕获C ++中的EXCEPTION_STACK_OVERFLOW结构化异常? [英] How can I guarantee catching a EXCEPTION_STACK_OVERFLOW structured exception in C++ under Visual Studio 2005?

查看:237
本文介绍了我如何保证在Visual Studio 2005中捕获C ++中的EXCEPTION_STACK_OVERFLOW结构化异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 我有一个包含崩溃 [ 1 ]。我相当肯定,这是由于一个堆栈。

  • 应用程序是多线程的。

  • 我正在使用启用C ++异常:是使用SEH异常(/ EHa)编译。

  • 我写了一个SE翻译器函数,并且用它来调用 _set_se_translator()

  • set_terminate() set_unexpected()

  • ,我必须在释放模式下运行,在重负载下,几天。在调试器下运行不是一个选项,因为应用程序无法执行得足够快,无法实现查看问题所需的运行时。

  • 我可以通过在执行时添加无限递归来模拟问题一个函数,然后测试捕获 EXCEPTION_STACK_OVERFLOW 异常。

  • 我有WinDBG设置为崩溃转储程序,获取所有其他崩溃问题的好信息,但不是此。崩溃转储将仅包含一个线程,即'Sleep()'。所有其他话题都已退出。

  • I have an application with a Poof-Crash[1]. I'm fairly certain it is due to a blown stack.
  • The application is Multi-Threaded.
  • I am compiling with "Enable C++ Exceptions: Yes With SEH Exceptions (/EHa)".
  • I have written an SE Translator function and called _set_se_translator() with it.
  • I have written functions for and setup set_terminate() and set_unexpected().
  • To get the Stack Overflow, I must run in release mode, under heavy load, for several days. Running under a debugger is not an option as the application can't perform fast enough to achieve the runtime necessary to see the issue.
  • I can simulate the issue by adding infinite recursion on execution of one of the functions, and thus test the catching of the EXCEPTION_STACK_OVERFLOW exception.
  • I have WinDBG setup as the crash dump program, and get good information for all other crash issues but not this one. The crash dump will only contain one thread, which is 'Sleep()'ing. All other threads have exited.

我试图导致了 EXCEPTION_STACK_OVERFLOW 异常。

有没有人知道如何在发布模式的运行期间保证有机会获得此异常?

Does anyone know how to guarantee getting a a chance at this exception during runtime in release mode?


  1. 崩溃:应用程序通过poof崩溃并消失,
  1. Poof-Crash: The application crashes by going "poof" and disappearing without a trace.

(考虑到这个网站的名称,我很惊讶这个问题不在这里了。)


  1. 强制问题更快,并允许捕获它与调试器。这是一个聪明的想法,但不幸的是,我不相信它会有所帮助。这个问题很可能是由于角落情况导致的无限递归。缩短堆栈不会更早地暴露问题,并且可能导致有效深层代码中的无关崩溃。


推荐答案

即使您已删除它,在windows xp之前的一切都不会(或更难)通常能够捕获堆栈溢出。随着xp的出现,您可以设置向量异常处理程序,在任何基于堆栈(结构化异常)处理程序之前堆栈溢出的机会(这是结构化异常处理程序基于堆栈的原因)。

但是真的没有太多你可以做,即使你能够捕获这样的异常。

他的博客中,cbrumme(对不起,没有他/她的真实姓名)讨论了一个堆栈页面邻近防护页面(一个,生成堆栈溢出),可能可用于回退。如果你可以挤压你的回退代码只使用一个堆栈页面 - 你可以释放尽可能多的逻辑允许。否则,应用程序在遇到堆栈溢出时几乎死了。只有另一个合理的事情,被困住,是写一个转储文件供以后调试。

Everything prior to windows xp would not (or would be harder) generally be able to trap stack overflows. With the advent of xp, you can set vectored exception handler that gets a chance at stack overflow prior to any stack-based (structured exception) handlers (this is being the very reason - structured exception handlers are stack-based).

But there's really not much you can do even if you're able to trap such an exception.

In his blog, cbrumme (sorry, do not have his/her real name) discusses a stack page neighboring the guard page (the one, that generates the stack overflow) that can potentially be used for backout. If you can squeeze your backout code to use just one stack page - you can free as much as your logic allows. Otherwise, the application is pretty much dead upon encountering stack overflow. The only other reasonable thing to do, having trapped it, is to write a dump file for later debugging.

希望,它有帮助。

这篇关于我如何保证在Visual Studio 2005中捕获C ++中的EXCEPTION_STACK_OVERFLOW结构化异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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