structured-exception

intermixing c++ exception handling and SEH (windows)

点点圈 提交于 2020-01-01 03:36:11
问题 I have a function in which I call getaddrinfo() to get an sockaddr* which targets memory is allocated by the system. As many may know, you need to call freeaddrinfo() to free the memory allocated by getaddrinfo(). Now, in my function, there are a few places, where I may throw an exception, because some function failed. My first solution was to incorporate the freeaddrinfo() into every if-block. But that did look ugly for me, because I would have had to call it anyways before my function

How can I handle an access violation in Visual Studio C++?

蓝咒 提交于 2019-12-30 07:27:28
问题 Usually an access violation terminates the program and I cannot catch a Win32 exception using try and catch . Is there a way I can keep my program running, even in case of an access violation? Preferably I would like to handle the exception and show to the user an access violation occurred. EDIT: I want my program to be really robust, even against programming errors. The thing I really want to avoid is a program termination even at the cost of some corrupted state. 回答1: In Windows, this is

Ways for an unmanaged Windows process to crash?

爷,独闯天下 提交于 2019-12-13 16:09:14
问题 I am trying to understand the ways in which an unmanaged user-mode Windows process can "crash" (which is really too much of a catch-all term). Here are the ways I know of so far: Unhandled Structured Exception Default UnhandledExceptionFilter: postmortem debugger in pre-Vista; WerFault in Vista+ Custom UnhandledExceptionFilter: may do whatever it likes, including exiting quietly? "Hard" crash (not sure if there's a technical term for this) E.g. hitting the stack overflow guard page while

Configuring floating point unit context in WIN32 vs WIN64

空扰寡人 提交于 2019-12-11 04:43:07
问题 I am attempting to write an unhandled exception filter ( see SetUnhandledExceptionFilter()) to use with Windows SEH to report invalid floating point operations. I'd like to trap the exception, print a stack trace, then disable floating point exceptions and resume execution with the resulting non-finite or not-a-number value. I wrote the simple program below to demonstrate the ability to catch the exception and resume execution. Note the use of #ifdef _WIN64, as the definition of the

How can I guarantee catching a EXCEPTION_STACK_OVERFLOW structured exception in C++ under Visual Studio 2005?

让人想犯罪 __ 提交于 2019-12-04 11:58:31
问题 Background 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

intermixing c++ exception handling and SEH (windows)

青春壹個敷衍的年華 提交于 2019-12-03 09:03:46
I have a function in which I call getaddrinfo() to get an sockaddr* which targets memory is allocated by the system. As many may know, you need to call freeaddrinfo() to free the memory allocated by getaddrinfo(). Now, in my function, there are a few places, where I may throw an exception, because some function failed. My first solution was to incorporate the freeaddrinfo() into every if-block. But that did look ugly for me, because I would have had to call it anyways before my function returns, so I came up with SEH`s try-finally... But the problem I encountered is, that it is not allowed to

How can I guarantee catching a EXCEPTION_STACK_OVERFLOW structured exception in C++ under Visual Studio 2005?

℡╲_俬逩灬. 提交于 2019-12-03 07:47:07
Background 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

How can I handle an access violation in Visual Studio C++?

不想你离开。 提交于 2019-12-01 01:30:21
Usually an access violation terminates the program and I cannot catch a Win32 exception using try and catch . Is there a way I can keep my program running, even in case of an access violation? Preferably I would like to handle the exception and show to the user an access violation occurred. EDIT: I want my program to be really robust, even against programming errors. The thing I really want to avoid is a program termination even at the cost of some corrupted state. In Windows, this is called Structured Exception Handling (SEH). For details, see here: http://msdn.microsoft.com/en-us/library

Why can't 64-bit Windows unwind user-kernel-user exceptions?

泄露秘密 提交于 2019-11-28 16:27:17
问题 Why can't 64-bit Windows unwind the stack during an exception, if the stack crosses the kernel boundary - when 32-bit Windows can? The context of this entire question comes from: The case of the disappearing OnLoad exception – user-mode callback exceptions in x64 Background In 32-bit Windows, if i throw an exception in my user mode code, that was called back from kernel mode code, that was called from my user mode code, e.g: User mode Kernel Mode ------------------ -------------------

What should I know about Structured Exceptions (SEH) in C++?

半世苍凉 提交于 2019-11-27 11:02:10
What important points about Structured Exceptions should every C++ developer know? They are the Win32 equivalent to Unix signals, and let you catch CPU exceptions such as access violation, illegal instruction, divide by zero. With the right compiler options (/EHa for Visual C++), C++ exceptions use the same mechanism as stack unwinding works properly for both C++ (user) exceptions and SEH (OS) exceptions. Unlike C++ exceptions, SEH are not typed but all share the same data structure which has an exception code (the cause) and additional information on what code faulted and what the CPU