User defined SEH with Release build

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Johnny

    #1

    User defined SEH with Release build

    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

  • William DePalo [MVP VC++]

    #2
    Re: User defined SEH with Release build

    "Johnny" <Johnny@discuss ions.microsoft. comwrote in message
    news:55E0DF65-6A67-4663-AAEA-BCF5EC1FAA80@mi crosoft.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_transla tor()? 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:



    Regards,
    Will


    Comment

    • Johnny

      #3
      Re: User defined SEH with Release build

      "William DePalo [MVP VC++]" wrote:
      Are you translating structured exceptions to C++ "typed" exceptions with
      _set_se_transla tor()? 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:
      >

      >
      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_translo tr() , instead, using the assemly code to
      directly replacing _EXCEPTION_REGI STRATION 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

      Comment

      • Carl Daniel [VC++ MVP]

        #4
        Re: User defined SEH with Release build

        Johnny wrote:
        "William DePalo [MVP VC++]" wrote:
        >Are you translating structured exceptions to C++ "typed" exceptions
        >with _set_se_transla tor()? 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_translo tr() , instead, using the assemly
        code to directly replacing _EXCEPTION_REGI STRATION 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


        Comment

        Working...