Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Handling Segfaults

Name: Anonymous 2016-09-09 22:18

What is the most portable way to catch segfaults together with their addresses and then resuming at the place where it happened? I.e. to handle array out of bounds exception by expanding array.

I know it is done with signal() on POSIX and with SetUnhandledExceptionFilter() on Windows. But you cant define signal() for Windows, because it has its own stripped down version, useful only for the purpose of handling CTRL-C.

Both don't signal() and SetUnhandledExceptionFilter() have no means of recovering from error.

Name: Anonymous 2016-09-12 11:11

You can do exception handling in Windows using Structured Exception Handling, or using Vectored Exception Handling (NT only). Most of the time, you'll either want to compiler to generate the code for you using __try/try or catch/__catch. Can't say this is portable, but you can make some shims or compatibility layers that would work on both Windows and POSIX. Or you could use C++, which has support for exception handling natively, for all its other faults.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List