seh

Is there a good way around the problems of structured exception handling (__try __except) with a multi-threaded server?

This article gives a good overview on why structured exception handling is bad. Is there a way to get the robustness of stopping your server from crashing, while getting past the problems mentioned in the article? I have a server software that runs about 400 connected users concurrently. But if there is a crash all 400 users are effec...

Is it legal and possible to access the return value in a finally block?

I wish to set a usererror string before leaving a function, depending on the return code and variable in the function. I currently have: Dim RetVal as RetType try ... if ... then RetVal = RetType.FailedParse end try endif ... finally select case RetVal case ... UserStr = ... end select end try ret...

Stack unwinding in case of structured exceptions

This question provides more clarity on the problem described here. I did some more investigation and found that the stack unwinding is not happening in the following piece of code: class One { public: int x ; }; class Wrapper { public: Wrapper(CString csText):mcsText(csText) { CString csTempText; csTempText.Format...

SEH, access violation and stack guard page

I've posted a question about validating a pointer's accessibility. The conclusion was either to use IsBadReadPtr to check the pointer, or SEH to catch the exception (and preferably to use neither, and debug the application, but that's not the issue here). IsBadReadPtr is said to be bad because, among other reasons, it would try to read ...

Mixing Win32 SEH with heap-allocated stack frames

Is there a way to escape the "one big stack" model of Win32 without crippling SEH? I'd like to be able to allocate stack frames on the heap, as a way to implement coroutines. However, my code is currently depending on SEH, and this article, a few pages down, says (relating to traversal of exception handlers, scanning, emphasis mine): ...

How to implement SEH (Structured Ecxeption Handling) in VB6?

Could someone provide some example on implementing SEH in VB6? Everything I've seen so far is in C++ ...

warning C6242: A jump out of this try-block forces local unwind

When we use SEH with __finally block, if we do return in __try block, it causes a local unwind. To Local unwind, the system need to approximately 1000 instructions. The local unwind causes a warning C6242. MSDN suggests using __leave keyword(with saving a return value). But I don't think it's a good idea. If we use __leave keyword, the...

64bit exceptions in WndProc silently fail

The following code will give a hard fail when run under Windows 7 32bit: void CTestView::OnDraw(CDC* /*pDC*/) { *(int*)0 = 0; // Crash CTestDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; // TODO: add draw code for native data here } However, if I try this on Windows 7 64bit, I just get ...

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

What important points about Structured Exceptions should every C++ developer know? ...

Windows Structured Exception Handling: simple test program will not compile.

#include <windows.h> int main() { int* i = (int*)malloc(sizeof(int)); *i = 5; __try { free(i); free(i); } __except { return -1; } return 0; } I am trying to learn more about windows SEH. My first test program is giving me some real trouble. I have looked at the msdn documenta...

When Does Visual Studio 6 Catch Structured Exceptions?

This is mostly curiosity, but I've been reading about the history of Visual Studio catching SEH exceptions in a C++ try-catch construct. I keep running across the assertion that older version Visual Studio with the /GX flag enabled would "somtimes" catch structured Win32 exceptions in a C++ catch block. Under what circumstances will Vi...

Forcing a coredump via Wine ignoring SEH

Hi, I'd like to force a coredump from a program (or see its memory at a specific time in some other way). There are a couple of problems though: I'm running it under wine (cannot run via winedbg, because the application detects it) The application uses exceptions / SEH / other handlers, which capture non-standard events Even attaching ...

What exactly is "application-defined" about UnhandledExceptionFilter?

MSDN describes UnhandledExceptionFilter as follows: "An application-defined function that passes unhandled exceptions to the debugger, if the process is being debugged." But this function is clearly supplied by the OS, in kernel32.dll according to that same page. So why do they call it an application-defined function? ...

Imitation of hardware exceptions

Can anyone tell me a code for next function, which raises EXCEPTION_FLT_STACK_CHECK or EXCEPTION_BREAKPOINT, for I could catch them in main func: int _tmain(int argc, _TCHAR* argv[]) { __try { FaultingStack(); // What I need to write in this function??? } __except(GetExceptionCode() == EXCEPTION_FLT_STACK_CHEC...

C++: how to throw EXCEPTION_FLT_UNDERFLOW?

Ok, it sounds strange, but I need a sample code, that throws EXCEPTION_FLT_UNDERFLOW. I already have code to handle that exception. Now I need sample, that throws this damn EXCEPTION_FLT_UNDERFLOW. Any advises? ...

Issue with exceptions being caught by Win32 message dispatcher

This is kinda a very low-level type question, but maybe someone here has some insight... I'm having an issue where unhandled SEH exceptions (such as Access Violations) are seemingly being caught at the Win32 message dispatch level, rather than terminating the program. I found the following reference blog, which explains the problem, but...