Skip to content

Interrupts (was Re: [Rd] X11 protocol errors ...) (PR#1068)

1 message · Luke Tierney

#
Martin wrote:

            
I'm surprised we don't get more of these sorts of things on UNIX.  Our
current UNIX interrupt handling approach takes an immediate LONGJMP
out of the signal handler no matter where the signal occurs (except
for two places where signals are suspended).  Any place where an
invariant is temporarily broken, any place where an assignment is not
yet complete, is a potential trouble spot.

I've been meaning to raise this issue at some point: I think we will
need to eventually spend some time re-examining how we want to handle
interrupts.  Right now on Windows/Mac interrupts are only processed at
special points in the evaluation process, which is a bit restrictive
(but perhaps unavoidable due to OS limitations).  On UNIX on the other
hand we LONGJUMP out of the signal handler except for the very few
places where the signal gets masked temporarily (GC and one place in
graphics I believe).  The UNIX approach is much too loose even now,
and it becomes even more untenable if we add any kind of threading
support.

We will I think have to come up with a cleaner model for very
selectively enabling interrupt processing, perhaps with some
integration with the external function registration mechanism Duncan
added recently (e.g. marking a function as one where LONGJMP's are
safe).  We will also need some means of controlling interrupt
behaviour from R, such as having some sort of without.interrupts and
with.interrupts functions to be able to program reliable interaction
with interrupts at the R level. (Another sort of thing we might
consider is suspending interrupts during on.exit processing.)

It's a farily big can of worms, and probably not urgent for now, but
we will need to look at it eventually.

luke