Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle seg faults under Windows?

Tags:

windows

fault

How can a Windows application handle segmentation faults? By 'handle' I mean intercept them and perhaps output a descriptive message. Also, the ability to recover from them would be nice too, but I assume that is too complicated.

like image 748
Nathan Osman Avatar asked Jan 02 '10 20:01

Nathan Osman


People also ask

How do you handle a segmentation fault?

It can be resolved by having a base condition to return from the recursive function. A pointer must point to valid memory before accessing it.

How do I find the cause of a seg fault?

Use debuggers to diagnose segfaults Start your debugger with the command gdb core , and then use the backtrace command to see where the program was when it crashed. This simple trick will allow you to focus on that part of the code.


1 Answers

Let them crash and let the Windows Error Reporting handle it - under Vista+, you should also consider registering with Restart Manager, so that you have a chance to save out the user's work and restart the application (like what Word/Excel/etc.. does)

like image 111
Ana Betts Avatar answered Sep 22 '22 22:09

Ana Betts