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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Exception handler

Exception handler

Scheduled Pinned Locked Moved C / C++ / MFC
hardwarehelpquestion
8 Posts 6 Posters 2 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.
  • D Offline
    D Offline
    Drugodrf
    wrote on last edited by
    #1

    I'm looking for a way to catch exceptions due to software or hardware errors and prevent my solution from breaking brutally, but I can't find anything complete. I have read the two main ways of handling exceptions, C ++ and SEH, but it seems to me that both do not include all cases that can happen. Can anyone help me ?

    Greg UtasG S 2 Replies Last reply
    0
    • D Drugodrf

      I'm looking for a way to catch exceptions due to software or hardware errors and prevent my solution from breaking brutally, but I can't find anything complete. I have read the two main ways of handling exceptions, C ++ and SEH, but it seems to me that both do not include all cases that can happen. Can anyone help me ?

      Greg UtasG Offline
      Greg UtasG Offline
      Greg Utas
      wrote on last edited by
      #2

      I think this article[^] might help.

      Robust Services Core | Software Techniques for Lemmings | Articles
      The fox knows many things, but the hedgehog knows one big thing.

      <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
      <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

      1 Reply Last reply
      0
      • D Drugodrf

        I'm looking for a way to catch exceptions due to software or hardware errors and prevent my solution from breaking brutally, but I can't find anything complete. I have read the two main ways of handling exceptions, C ++ and SEH, but it seems to me that both do not include all cases that can happen. Can anyone help me ?

        S Offline
        S Offline
        SeeSharp2
        wrote on last edited by
        #3

        Drugodrf wrote:

        include all cases that can happen.

        There is no way to handle all cases. For example, what it the power cord is pulled? Or the OS crashes? Follow best practices and you'll get most all of the likely happenings.

        D 1 Reply Last reply
        0
        • S SeeSharp2

          Drugodrf wrote:

          include all cases that can happen.

          There is no way to handle all cases. For example, what it the power cord is pulled? Or the OS crashes? Follow best practices and you'll get most all of the likely happenings.

          D Offline
          D Offline
          Drugodrf
          wrote on last edited by
          #4

          Greg Utas, thanks for article: i read it as soon as possible.

          DevParty: ok, all cases is too much, but most of the cases?
          I've tried both ways (exception C++ and SEH), but, for example, they catch division by zero, but not a string copy error.

          V 1 Reply Last reply
          0
          • D Drugodrf

            Greg Utas, thanks for article: i read it as soon as possible.

            DevParty: ok, all cases is too much, but most of the cases?
            I've tried both ways (exception C++ and SEH), but, for example, they catch division by zero, but not a string copy error.

            V Offline
            V Offline
            Victor Nijegorodov
            wrote on last edited by
            #5

            Drugodrf wrote:

            they catch division by zero, but not a string copy error.

            What is a "string copy error"?

            J 1 Reply Last reply
            0
            • V Victor Nijegorodov

              Drugodrf wrote:

              they catch division by zero, but not a string copy error.

              What is a "string copy error"?

              J Offline
              J Offline
              jschell
              wrote on last edited by
              #6

              In C/C++ you can copy a buffer to another, often a char array but not always, and unintentionally write past the end of the target. Less often but still possible you can write past the beginning as well. So for example if you have a char[5] and you write 6 bytes to that you have a problem. The impact of this depends on where the buffer actually lives in the memory space and often what processing has been happening up to that point.

              V L 2 Replies Last reply
              0
              • J jschell

                In C/C++ you can copy a buffer to another, often a char array but not always, and unintentionally write past the end of the target. Less often but still possible you can write past the beginning as well. So for example if you have a char[5] and you write 6 bytes to that you have a problem. The impact of this depends on where the buffer actually lives in the memory space and often what processing has been happening up to that point.

                V Offline
                V Offline
                Victor Nijegorodov
                wrote on last edited by
                #7

                Thank you for the reply. However, I just would like to know what exception is about to be thrown in case of (as stated by OP in [Re: Exception handler - C / C++ / MFC Discussion Boards](https://www.codeproject.com/Messages/5820979/Re-Exception-handler) ) "a string copy error". :confused:

                1 Reply Last reply
                0
                • J jschell

                  In C/C++ you can copy a buffer to another, often a char array but not always, and unintentionally write past the end of the target. Less often but still possible you can write past the beginning as well. So for example if you have a char[5] and you write 6 bytes to that you have a problem. The impact of this depends on where the buffer actually lives in the memory space and often what processing has been happening up to that point.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  jschell wrote:

                  you write 6 bytes to that you have a problem.

                  Of course, but not an exception. Which is why you are always reminded to use the strxxx_s versions which include bounds checking. But you have to work quite hard to write past the beginning of a buffer.

                  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