Asynchronous Exceptions in Haskell

Have you ever pressed the "stop" button in your web browser? Did it always work? Should PLs make it easier for developers to make it work?

Asynchronous Exceptions in Haskell

Asynchronous exceptions, such as timeouts, are important for robust, modular programs, but are extremely difficult to program with — so much so that most programming languages either heavily restrict them or ban them altogether. We extend our earlier work, in which we added synchronous exceptions to Haskell, to support asynchronous exceptions too. Our design introduces scoped combinators for blocking and unblocking asynchronous interrupts, along with a somewhat surprising semantics for operations that can suspend. Uniquely, we also give a formal semantics for our system.
PS: this was mentioned some time ago on LtU, but seems to be gone.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Deja Vu

We seem to (re)read the same papers these days :)

I was rereading this one while thinking about what "safe" semantics for the following Lisp code would be:

(with-timeout N
  (unwind-protect
      ACQUIRE-RESOURCE
    RELEASE-RESOURCE))

UNWIND-PROTECT is a commonly used idiom in resource allocation situations, but in presence of asynchronous exceptions (timeouts, aborts) it might still be unsafe: resources could leak if an asynchronous exception is raised after ACQUIRE-RESOURCE, but right before RELEASE-RESOURCE executes.

Note that RELEASE-RESOURCE is not protected and it cannot easily be done, because it might take arbitrary long, and timeouts (generally all aborts) should be timely at least to some extent.

So, asynchronous exceptions are unsafe in the presence of side-effecting code, and the question is whether this can be repaired somehow? Or maybe allow only a restricted version? Or none at all?

Ideally, I would like to keep code safe by default, i.e. although it was not written with async exceptions in mind it does not break in their presence.

I am pretty sure the Ada camp also has something to say on this topic. Can anybody recommend papers?

Ada

This paper might be of interest.

I have a proposal

Described here. I'm going to present this at TFP 2005.

STM?

Could any of this be made simpler if Concurrent Haskell didn't use MVars, but STM as the foundation? It seems that only inside atomically would you need to suspend signals, and not even within the STM action, only within the atomically function.