MPS issue job004085

TitleMPS doesn't cooperate well with other SEGV handlers
Assigned userNick Barnes
DescriptionA client program which handles SEGV and expects the signal context to be meaningful will not work with the MPS on Linux or FreeBSD (and maybe not on MacOS).
AnalysisChristian Schafmeister has asked [1] about this because CLASP has SEGV-handling code (e.g. to enter their debugger when their LISP code blows up the stack and hits a guard page).
The fundamental problem is that, although the POSIX sigaction(2) interface does tell the caller about a previously-installed handler, it provides no mechanism for calling that handler in the manner that it expects (for example, with or without its own signal stack, depending on its SA_ONSTACK flag). We can do a best effort but can't get all the way there. On Linux and FreeBSD at present (see protsgix.c) we reinstall the previous handler and call kill() to invoke it, which will run the handler but in a context in which the MPS handler is on top of the stack, not the context of the original exception.
On MacOS we use the Mach interface for managing hardware exceptions, which has a similar problem (see protxc.c).
We must look into this in more detail with Schafmeister/ThirdLaw.
How foundcustomer
Created byNick Barnes
Created on2018-07-05 17:56:48
Last modified byNick Barnes
Last modified on2018-07-05 17:56:48
History2018-07-05 NB Created.