From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: Core dump when throwing an exception from a resumed partial continuation Date: Thu, 21 Mar 2013 10:43:59 +0100 Message-ID: <87wqt1w0io.fsf@pobox.com> References: <51438C23.6020605@4dst.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1363859057 18630 80.91.229.3 (21 Mar 2013 09:44:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Mar 2013 09:44:17 +0000 (UTC) Cc: Andrew Gaylard , guile-devel@gnu.org To: Brent Pinkney Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Mar 21 10:44:39 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UIc33-0002be-Tf for guile-devel@m.gmane.org; Thu, 21 Mar 2013 10:44:38 +0100 Original-Received: from localhost ([::1]:48123 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIc2g-0000QV-Mg for guile-devel@m.gmane.org; Thu, 21 Mar 2013 05:44:14 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIc2a-0000P8-Ma for guile-devel@gnu.org; Thu, 21 Mar 2013 05:44:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UIc2V-0001Co-Ij for guile-devel@gnu.org; Thu, 21 Mar 2013 05:44:08 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:43975 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UIc2V-0001CP-En for guile-devel@gnu.org; Thu, 21 Mar 2013 05:44:03 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 8C434CBB3; Thu, 21 Mar 2013 05:44:02 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=5YHkmYPVGqY6RiqvClSeF1jwofw=; b=oy2fzR HiAiXLuRr4ScqMFhZ4YOEpKjUFai36x91UTmeBqjWa/DdPKh/MkK0QCPWObth+Md LOQHSm+TGyIjb0Olx5cMpIepi2uPOBvSiGUpKOFxNoBtHB5Vg+prddhCU9WaDArw gpz4qD1+t0QdAIYPovaJYFKt1EqtA5vEbivbo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=Ss/a30IZr9DuVsZaCVbE4nvSic/oqlrl YsWRzXPeO9Rmhp6iNm9DaiNt/CaAIv2bYW3DSH7oJP85MIx19CBv0GLswddaw9Tm VS9vt0qSCvQrdl3stFoPIGY6jp7IqV8i9YyPOCQRgarFbvEL5LJgaeKmOcXywxxP uYT10AKlXnU= Original-Received: from a-pb-sasl-quonix.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 824E2CBB2; Thu, 21 Mar 2013 05:44:02 -0400 (EDT) Original-Received: from badger (unknown [88.160.190.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id DACA1CBB1; Thu, 21 Mar 2013 05:44:01 -0400 (EDT) In-Reply-To: <51438C23.6020605@4dst.com> (Brent Pinkney's message of "Fri, 15 Mar 2013 23:01:23 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) X-Pobox-Relay-ID: DCBD841E-920B-11E2-876C-B7660E5B5709-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 208.72.237.25 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:15949 Archived-At: On Fri 15 Mar 2013 22:01, Brent Pinkney 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/