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-15 18:40

I found it to be harder that I thought, because there is just no way to restore execution without ucontext_t on Unix and PCONTEXT on Windows. Although one can express sigaction's ucontext_t through PCONTEXT, their data are non-portable even across Linux systems. I.e. instruction pointer could be called PC, IP, Rip, Eip, etc...

What a bullshit! Why there is still no portable context library? Pthreads wont help handling segfault either and are no pthreads on Windows.

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