[r6rs-discuss] [Formal] returning exception handlers easily trigger infinite loops

From: Robby Findler <robby>
Date: Wed Jan 31 01:56:33 2007

---
This message is a formal comment which was submitted to formal-comment_at_r6rs.org, following the requirements described at: http://www.r6rs.org/process.html
---
# type of issue: defect
# priority: as you decide
# R6RS component: Exceptions
# version of the report: 5.92
# one-sentence summary of the issue:
  returning exception handlers easily trigger infinite loops
# full description of the issue:
As I understand the current informal spec (with help from Mike) and as
is shown in the operational semantics, exception handlers that return
to a `raise' very easily get into infinite loops. (Indeed, without
effects or dispatching on the exception itself, it seems impossible to
avoid an infinite loop when a handler returns.)
For example these programs:
  (with-exception-handler (lambda (x) x) (lambda () (raise 1)))
  (with-exception-handler (lambda (x) x) (lambda () (car '())))
both result in infinite loops. (Try it out! :)
I believe that there is a simple fix to this, namely to make the
implicit raise (the one that gets triggered when the handler returns)
be in the same context as call to the handler. That is, in the handler
context that does not contain the handler that just returned.
>From the operational semantics point of view, it means changing the
begin expression in the 6xraise rule from this:
(begin (handlers v_1 ... (v_2 v_3)) (raise (condition "handler returned")))
to this:
(handlers v_1 ... (begin (v_2 v_3) (raise (condition "handler returned"))))
Robby
Received on Sun Jan 28 2007 - 09:56:32 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC