Exception handler
-
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 ?
-
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 ?
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. -
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 ?
-
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.
-
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.Drugodrf wrote:
they catch division by zero, but not a string copy error.
What is a "string copy error"?
-
Drugodrf wrote:
they catch division by zero, but not a string copy error.
What is a "string copy error"?
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.
-
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.
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:
-
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.
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.