unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Brent Pinkney <brp@4dst.com>
Cc: Andrew Gaylard <apg@4dst.com>, guile-devel@gnu.org
Subject: Re: Core dump when throwing an exception from a resumed partial continuation
Date: Thu, 21 Mar 2013 10:43:59 +0100	[thread overview]
Message-ID: <87wqt1w0io.fsf@pobox.com> (raw)
In-Reply-To: <51438C23.6020605@4dst.com> (Brent Pinkney's message of "Fri, 15 Mar 2013 23:01:23 +0200")

On Fri 15 Mar 2013 22:01, Brent Pinkney <brp@4dst.com> 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/



  parent reply	other threads:[~2013-03-21  9:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-15 21:01 Core dump when throwing an exception from a resumed partial continuation Brent Pinkney
2013-03-15 21:30 ` Andy Wingo
2013-03-19  8:11   ` Andrew Gaylard
2013-03-21  9:43 ` Andy Wingo [this message]
2013-03-21 13:53   ` Andrew Gaylard
2013-03-21 15:34     ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wqt1w0io.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=apg@4dst.com \
    --cc=brp@4dst.com \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).