[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Core dump when throwing an exception from a resumed partial continua
From: |
Andy Wingo |
Subject: |
Re: Core dump when throwing an exception from a resumed partial continuation |
Date: |
Thu, 21 Mar 2013 10:43:59 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) |
On Fri 15 Mar 2013 22:01, Brent Pinkney <address@hidden> writes:
> When I resume the continuation in another thread, all works perfectly
> UNLESS the continued execution throws and exception.
> Then guile exits with a core dump.
>
> By contrast if I resume the continuation in the same thread and then
> throw and exception all works as expected.
I think I know what this is.
So, a delimited continuation should capture that part of the dynamic
environment made in its extent. (See Oleg Kiselyov and Chung-Chieh
Shan's "Delimited Dynamic Binding" paper.) That is what Guile does, for
fluids, prompts, and dynamic-wind blocks.
Our implementation of exception handling uses a fluid,
%exception-handler (boot-9.scm:86). However that fluid references a
stack of exception handlers on the heap. There is the problem: an
exception in a reinstated delimited continuation continuation will walk
the captured exception handler stack from the heap, not from its own
dynamic environment. Therefore it could abort to a continuation that is
not present on the new thread.
The solution is to have the exception handler find the next handler from
the dynamic environment. This will need a new primitive to walk the
dynamic stack, I think.
I can't look at this atm as I broke my arm (!) and so typing is tough.
For now as a workaround I suggest you put a catch #t in each of your
delimited continuations. This way all throws will be handled by catches
established by the continuation.
Regards,
Andy
--
http://wingolog.org/