By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,793 Members | 1,257 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,793 IT Pros & Developers. It's quick & easy.

User defined SEH with Release build

P: n/a
Hi guys,

I created a user-defined SEH by following Crash Course SEH article by Matt
Pietrek. When building the app in Debug mode, it has no problem catching
exception and entering the user defined hanlder. In Release mode, however,
the app would just crash at the point where the exception occurs.

Why is that? Is there any way to solve this?

Thanks in advance,
Johnny

Aug 21 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Johnny" <Jo****@discussions.microsoft.comwrote in message
news:55**********************************@microsof t.com...
I created a user-defined SEH by following Crash Course SEH article by Matt
Pietrek. When building the app in Debug mode, it has no problem catching
exception and entering the user defined hanlder. In Release mode,
however,
the app would just crash at the point where the exception occurs.

Why is that? Is there any way to solve this?
It may be the optimizer that is biting you.

Are you translating structured exceptions to C++ "typed" exceptions with
_set_se_translator()? If so, what is probably happening is that the compiler
sees no way that the C++ code could throw an exception so it just goes ahead
and removes the try / catch stuff.

If that's your problem you can "fix" it by compiling with the /EHa switch.

There is quite a lot to say on this subject and Doug does it best here:

http://members.cox.net/doug_web/eh.htm

Regards,
Will
Aug 21 '06 #2

P: n/a
"William DePalo [MVP VC++]" wrote:
Are you translating structured exceptions to C++ "typed" exceptions with
_set_se_translator()? If so, what is probably happening is that the compiler
sees no way that the C++ code could throw an exception so it just goes ahead
and removes the try / catch stuff.

If that's your problem you can "fix" it by compiling with the /EHa switch.

There is quite a lot to say on this subject and Doug does it best here:

http://members.cox.net/doug_web/eh.htm

Regards,
Will
Thanks for the reply, William,

I have tried the /Eha switch and still got the same problem.
I did not use the _set_se_translotr() , instead, using the assemly code to
directly replacing _EXCEPTION_REGISTRATION structure. It is a method
described in the Matt Pietrek's article and is commonly seen and used on the
net.

However, I still think it's a compiler related issue, as the method would
work fine with VC6 compilation (both Debug and Release) and not in VC 2005
(only Debug mode works)

P.S.
You can find Matt Pietrek's article here:
http://www.microsoft.com/msj/0197/Ex...Exception.aspx

Any more ideas?
Thanks again,
Johnny
Aug 22 '06 #3

P: n/a
Johnny wrote:
"William DePalo [MVP VC++]" wrote:
>Are you translating structured exceptions to C++ "typed" exceptions
with _set_se_translator()? If so, what is probably happening is that
the compiler sees no way that the C++ code could throw an exception
so it just goes ahead and removes the try / catch stuff.

If that's your problem you can "fix" it by compiling with the /EHa
switch.

There is quite a lot to say on this subject and Doug does it best
here:

http://members.cox.net/doug_web/eh.htm

Regards,
Will

Thanks for the reply, William,

I have tried the /Eha switch and still got the same problem.
I did not use the _set_se_translotr() , instead, using the assemly
code to directly replacing _EXCEPTION_REGISTRATION structure. It is
a method described in the Matt Pietrek's article and is commonly
seen and used on the net.

However, I still think it's a compiler related issue, as the method
would work fine with VC6 compilation (both Debug and Release) and not
in VC 2005 (only Debug mode works)

P.S.
You can find Matt Pietrek's article here:
http://www.microsoft.com/msj/0197/Ex...Exception.aspx
Note the ancient date on the article - it's nearly 10 years old.

I have a suspicion that your attempt at defining an exception record is
running afoul of new security measures that have been put into the
compiler/runtime libraries to block exception-based attack vectors. I don't
know any details of what's been changed, but I know that changes were made -
starting in VC7, I think. Have you tried VC7 or 7.1, or are VC6 and 8 your
only data points?

-cd
Aug 22 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.