Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Is there anyway to make SEH works when stask is broken

Is there anyway to make SEH works when stask is broken

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tal Rashas Guardianship
    wrote on last edited by
    #1

    SEH is exactly a good solution for exception handling, but it depends on the stack to call the user-defined exeception handler function, that means, when exception occurs, the OS catch the exception immediately, and it will call the user-defined callback to give the control to the application. If the trouble which caused the exception makes the stack broken, the calling to the user-defined callback may not success, in this situation, the application will not be notified that an exception occurred. Is there anyway to catch the exception in all the cases? whether stack is OK or NG, the mechanism should work. Thanks.

    S S R 3 Replies Last reply
    0
    • T Tal Rashas Guardianship

      SEH is exactly a good solution for exception handling, but it depends on the stack to call the user-defined exeception handler function, that means, when exception occurs, the OS catch the exception immediately, and it will call the user-defined callback to give the control to the application. If the trouble which caused the exception makes the stack broken, the calling to the user-defined callback may not success, in this situation, the application will not be notified that an exception occurred. Is there anyway to catch the exception in all the cases? whether stack is OK or NG, the mechanism should work. Thanks.

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      Exception handling in general needs to walk the call stack to find handlers. Maybe you can find some way of using C's longjmp to do your exception handling?

      T 1 Reply Last reply
      0
      • T Tal Rashas Guardianship

        SEH is exactly a good solution for exception handling, but it depends on the stack to call the user-defined exeception handler function, that means, when exception occurs, the OS catch the exception immediately, and it will call the user-defined callback to give the control to the application. If the trouble which caused the exception makes the stack broken, the calling to the user-defined callback may not success, in this situation, the application will not be notified that an exception occurred. Is there anyway to catch the exception in all the cases? whether stack is OK or NG, the mechanism should work. Thanks.

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        I think that if the stack is "broken" you've got more to worry about than SEH not working.

        Steve

        T 1 Reply Last reply
        0
        • T Tal Rashas Guardianship

          SEH is exactly a good solution for exception handling, but it depends on the stack to call the user-defined exeception handler function, that means, when exception occurs, the OS catch the exception immediately, and it will call the user-defined callback to give the control to the application. If the trouble which caused the exception makes the stack broken, the calling to the user-defined callback may not success, in this situation, the application will not be notified that an exception occurred. Is there anyway to catch the exception in all the cases? whether stack is OK or NG, the mechanism should work. Thanks.

          R Offline
          R Offline
          Rolf Kristensen
          wrote on last edited by
          #4

          I have very good succes with __try / __except for catching unhandled exceptions (Instead of using SetUnhandledExceptionFilter or set_se_translator with /EHa compiler option). Though one still need to set the following exception handlers: _set_purecall_handler( ); _set_invalid_parameter_handler( ); Where one raises an exception inside the exception handlers to get the proper exception information to create a useful minidump. But yes sometimes the memory overwrite be so bad that the exception information cannot give a useful call stack.

          T 1 Reply Last reply
          0
          • R Rolf Kristensen

            I have very good succes with __try / __except for catching unhandled exceptions (Instead of using SetUnhandledExceptionFilter or set_se_translator with /EHa compiler option). Though one still need to set the following exception handlers: _set_purecall_handler( ); _set_invalid_parameter_handler( ); Where one raises an exception inside the exception handlers to get the proper exception information to create a useful minidump. But yes sometimes the memory overwrite be so bad that the exception information cannot give a useful call stack.

            T Offline
            T Offline
            Tal Rashas Guardianship
            wrote on last edited by
            #5

            Thanks

            1 Reply Last reply
            0
            • S Stephen Hewitt

              I think that if the stack is "broken" you've got more to worry about than SEH not working.

              Steve

              T Offline
              T Offline
              Tal Rashas Guardianship
              wrote on last edited by
              #6

              Yes I think so. But I don't want to recover from the error in this case, I just want to record some useful information when an exception happened. Such as error thread ID

              1 Reply Last reply
              0
              • S Stuart Dootson

                Exception handling in general needs to walk the call stack to find handlers. Maybe you can find some way of using C's longjmp to do your exception handling?

                T Offline
                T Offline
                Tal Rashas Guardianship
                wrote on last edited by
                #7

                I think the workflow is, firstly I catch an exception, and then jump to where to handle this exception. I wonder how to catch such an exception when the stack was broken.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups