Title | MPS doesn't cooperate well with other SEGV handlers |
Status | open |
Priority | optional |
Assigned user | Nick Barnes |
Organization | Ravenbrook |
Description | A 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). |
Analysis | Christian 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 found | customer |
Evidence | [1] https://info.ravenbrook.com/mail/2018/07/03/19-36-08/0/ |
Created by | Nick Barnes |
Created on | 2018-07-05 17:56:48 |
Last modified by | Nick Barnes |
Last modified on | 2018-07-05 17:56:48 |
History | 2018-07-05 NB Created. |