From: olk on
I've some code which creates its own stackframe and does some kine of
context switching (using inline assembler). The code works until the
function of the new context throws an exception. Even if I've installed
an exception handler (try/catch block) I get an unhandled exception
fault (I debugged it with MS VC - catch caluse note entered even not the
catch(...).
I guess on windows some special code is required for my own stackframe
in order to the exception handling correct?!

Any hints are welcome.

Oliver
From: Jochen Kalmbach [MVP] on
Hi olk!

> I've some code which creates its own stackframe and does some kine of
> context switching (using inline assembler).

Why not switch the whole stack?
Or: Why not use CreateFiber? and SwitchToFiber?

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
From: olk on
Jochen Kalmbach [MVP] schrieb:
> Hi olk!
>
>> I've some code which creates its own stackframe and does some kine of
>> context switching (using inline assembler).
>
> Why not switch the whole stack?

The code works similiar to ucotnext -> makecontext()/swapcontext() etc.
What it doesis: it creates an stack on an range in the memory. It saves
the registers. Such context objects can bes sappwed. So it does swap the
whole stack (assigned to it).

> Or: Why not use CreateFiber? and SwitchToFiber?
Has some problems. for instance you can not move fibers between threads.
You have the ugly ConvertThreadToFiber()/ConvertFiberToThread() stuff etc.

I need to know how to get the surounding exception handler recognized.
From: Alexander Grigoriev on
A thread context contains stack limits. If stack pointer outside of those
limits, expection can't be handled.

"olk" <oliver.kowalke(a)gmx.de> wrote in message
news:hngkap$bro$02$1(a)news.t-online.com...
> I've some code which creates its own stackframe and does some kine of
> context switching (using inline assembler). The code works until the
> function of the new context throws an exception. Even if I've installed an
> exception handler (try/catch block) I get an unhandled exception fault (I
> debugged it with MS VC - catch caluse note entered even not the
> catch(...).
> I guess on windows some special code is required for my own stackframe in
> order to the exception handling correct?!
>
> Any hints are welcome.
>
> Oliver


From: olk on
Alexander Grigoriev schrieb:
> A thread context contains stack limits. If stack pointer outside of those
> limits, expection can't be handled.

stacksize is 64kB - the code works. If I throw an exception the
sourounding exceptio nhandler is not invoked:

try
{
throw std::runtime_erro("abc"); // app is aborted because unhandled
exception
}
catch( std::exception const& e)
{}
catch(...)

I'm looking through MSDN and I saw some articesl about Frame-based
Exception Handling (SEH) etc. but I'm not sure if this would point me to
a solution.
{}