Re: try/catch with new rtti & /GX doesn't want to catch exception...



You can use SEH in C++ code. You just can't mix C++ EH with SEH in the
same function. I don't want to get into a philosophical debate about
proper style, but I'll give you my recommendation. SEH should only be used
in two cases:

1) Wrapping very short sequences of code where you have no control over
whether the code causes an exception, but you must simply ignore an
exception if it happens. Typically this means calls out to library code
you don't control. This is generally bad practice because the library can
be left in an inconsistent/insecure state, but sometimes production code
simply has no alternative.
2) Wrapping entire programs/threads, i.e. the __try should be at the base
of a callstack. This is the typical case where you would rather perform
some sort of graceful shutdown/restart if something unexpected happens.
The exception is usually considered unrecoverable and the current process
should end in any case. This use is less evil since the process will end
shortly, but since the process could still be in an inconsistent state,
really anything you do could be bad.

For both of these cases, it's trivial to place the SEH __try in its own
function.

To address your question, the fact is that we (MS compiler weenies) do
everything we can to ensure /EHa does what you want in terms of catching
SEH, and it does work in almost all cases. However, the problem is
extremely complicated and we find corner cases that aren't covered often
enough that we don't recommend using it for that purpose. Instead, stick
to SEH, which is a bit simpler and was actually designed for that purpose.

--
Russ Keldorph
russellk@xxxxxxxxxxxxxxxxxxxx (Remove the 'online.' from my address to
reach me.)

This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm";
--------------------
> From: "Steve Maillet \(eMVP\)" <nospam1@xxxxxxxxxxxxxxxxxxxxxxx>
> References: <1118945119.413991.226360@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
<9DS2BL1dFHA.3404@xxxxxxxxxxxxxxxxxxxxx>
> Subject: Re: try/catch with new rtti & /GX doesn't want to catch
exception...
> Date: Wed, 22 Jun 2005 14:01:14 -0400
> Lines: 12
> X-Priority: 3
> X-MSMail-Priority: Normal
> X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
> X-RFC2646: Format=Flowed; Original
> Message-ID: <#1iKpR1dFHA.640@xxxxxxxxxxxxxxxxxxxx>
> Newsgroups: microsoft.public.windowsce.embedded.vc
> NNTP-Posting-Host: cpe-204-210-85-141.maine.res.rr.com 204.210.85.141
> Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
> Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.windowsce.embedded.vc:9673
> X-Tomcat-NG: microsoft.public.windowsce.embedded.vc
>
> Well, hang on then. We are not supposed to mix SEH with C++ exception
> handling so how are we supposed to write code that can catch SEH
exceptions
> in C++ code? If /EHa isn't going to guarantee I can catch any SEH
exception
> then the whole thing is rather seriously flawed in my view.
>
> --
> Steve Maillet
> EmbeddedFusion
> www.EmbeddedFusion.com
> smaillet at EmbeddedFusion dot com
>
>
>

.



Relevant Pages

  • Re: initial lang spec: SXIL...
    ... Shouldn't some of that functionality be moved into the exception ... but, of course, natively using SEH requires compiler support. ... throws a fixed exception code in my case, and generic handlers are used. ... It took many years, and a language review, before I realized that my fond ...
    (comp.lang.misc)
  • Re: CORRECTION Re: confused by exception handling in VC 2008
    ... translator to convert asynchronous SEH exceptions into synchronous C++ ... going to combine SEH and C++ exception handling, you should at least do it ...
    (microsoft.public.vc.mfc)
  • [EXPL] Alphanumeric GetPC Code and Shellcode Encoder-Decoder
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... In addition attached is an uppercase alphanumeric shellcode ... new SEH. ... Then it causes an exception, passing execution to the new SEH. ...
    (Securiteam)
  • Re: Implementing Exception Handling in a VM
    ... Given that the implementing language has SEH, can ... I leverage this fact to add exception support in my Pascal-like ... handling system in your VM. ...
    (comp.compilers)
  • Re: Try Finally...
    ... Okay, so one big part of Delphi SEH requires conversions for system exceptions, ... assertions and other Delphi exceptions into Delphi SEH structures. ... In my tests no Finally code was executed, the call to @Assert actually ... I.e. SEH is not working at all when the various exception conditions do ...
    (comp.lang.pascal.delphi.misc)