When does it make sense to process a SIGSEGV signal?

Searching here and there I found some supposedly valid cases, but none of them gave a good (or any) explanation of why this was the best (or only) choice.

Here are the cases:

  • Try some cleanup before failure.
  • Submit a friendly bug report to the user and maybe send a bug report.
  • Use it for debugging.
  • Try to perform a full recovery of your program.

Here are my thoughts on cases:

  • SIGSEGV signals should not be in the first place, but again there is Murphy's law, and there are some resources that the OS will not release implicitly after the program crashes (I think about semaphores or shared memory).
  • Again, there is Murphy's law. Displaying a dialog when everything goes wrong and asking the user for permission to send an automatic report seems very good for both the user and the developer. (I don’t remember if any of the program error messages I use have ever mentioned a lack of segmentation, I think I’ll start to notice now.)
  • I never thought about that. The debugger and core dump look like a more efficient approach.
  • As far as I know, this is either impossible or illogical, since the state of the program is damaged, which makes the execution unpredictable (this is another good argument against (1), (2) and (3)). I do not know if there is a very specific case where this might make sense. This reminds me of the argument for turning statements into production software: sometimes erroneous execution is better than lack of execution, sometimes it is aviation software, etc.

So:

  • Are there any good reasons to process a SIGSEGV signal?
  • Are any of the above cases really valid? Why or why not?
  • Why are we allowed to process SIGSEGV in the first place?
+6
source share
1 answer

You have a program that must constantly work with 24/7 processing (for example, process messages), and uses a third-party component to perform some part of the processing. This third-party component sometimes fails with SIGSEGV.

Obviously, the best long-term solution is to force the supplier to fix the component or use another component, but the short-term solution is to register the error and continue to work.

0
source

Source: https://habr.com/ru/post/970139/


All Articles