From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.bugs,gmane.lisp.guile.devel Subject: Re: exit & dynamic wind Date: Wed, 30 Mar 2011 23:25:39 +0200 Message-ID: References: <87fwqc3r1h.fsf@ossau.uklinux.net> <87mxkcfojs.fsf@ossau.uklinux.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1301520353 2647 80.91.229.12 (30 Mar 2011 21:25:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 30 Mar 2011 21:25:53 +0000 (UTC) Cc: bug-guile@gnu.org, Ian Price , guile-devel To: Neil Jerram Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Wed Mar 30 23:25:49 2011 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q52ta-00074P-Gg for guile-bugs@m.gmane.org; Wed, 30 Mar 2011 23:25:48 +0200 Original-Received: from localhost ([127.0.0.1]:42770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q52tY-0007hK-47 for guile-bugs@m.gmane.org; Wed, 30 Mar 2011 17:25:40 -0400 Original-Received: from [140.186.70.92] (port=53875 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q52tQ-0007fn-Nx for bug-guile@gnu.org; Wed, 30 Mar 2011 17:25:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q52tO-0006ka-8y for bug-guile@gnu.org; Wed, 30 Mar 2011 17:25:32 -0400 Original-Received: from a-pb-sasl-sd.pobox.com ([64.74.157.62]:40931 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q52tO-0006kT-4s; Wed, 30 Mar 2011 17:25:30 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id CF2424795; Wed, 30 Mar 2011 17:27:15 -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=bJnmFycCgRk8ri6njijNzOPdhX0=; b=TaFSqG 5mvCsY+MLO1AAacnD++PQYj5cwQQNtBnj9wSw3dY33/9ERY8WQBK+KQYzm6Rp/Yo DxMJcWJbAot5SuoSlgf91P1CrQJxklnX82Uyc6AyzK7NS7qJz9NMm3gFzST2dEqc EgpRJNaAV6jS2IcqKlTImsr5udn7dTW/VaQKE= 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=bsBna+z23J7lmQqBTOj/EFMg5+oDj7Hd KokEheeIespKG7++acbg577LD8m23Xph7lhHLFWG53JSop/pIk9w1XTjK2rMC9Cg mI3Q3K8eEwgi8+aDFkDRtoMS9scxRlagrIzxo5eNkyVIej7RVpsgZ5uw9B2kunY5 ajRVn1nreqM= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 9EBFC4794; Wed, 30 Mar 2011 17:27:11 -0400 (EDT) Original-Received: from unquote.localdomain (unknown [90.164.198.39]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id 7B5454787; Wed, 30 Mar 2011 17:27:07 -0400 (EDT) In-Reply-To: <87mxkcfojs.fsf@ossau.uklinux.net> (Neil Jerram's message of "Wed, 30 Mar 2011 19:31:19 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Pobox-Relay-ID: 796BC784-5B14-11E0-9C59-E8AB60295C12-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 64.74.157.62 X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:5391 gmane.lisp.guile.devel:12096 Archived-At: On Wed 30 Mar 2011 20:31, Neil Jerram writes: > Andy Wingo writes: > >>>> | GEN guile-procedures.texi >>>> | guile: uncaught throw to wrong-type-arg: (#f Wrong type (expecting ~A): ~S (exact integer (#t # #)) ((#t # #))) >> >> This, it turns out, was something more pernicious, fixed in >> 572eef50c2d902d34427945dd504ba03af666e48. > > Thanks for the fix. I'm afraid I struggled to understand the change, > though - although I admit it may be largely my fault, as I'm not up to > speed with VM or prompt internals. Nevertheless, would it perhaps be > worth a bit more commenting or a test, for future readers? As for explanations... Catch and throw are implemented using fluids and prompt and abort. (A discussion of that is here: http://wingolog.org/archives/2010/02/14/sidelong-glimpses .) An abort can pass arguments to the prompt's abort handler. It does so by pushing those values and a number-of-values marker onto the Scheme stack, after the Scheme and dynamic stacks are unwound to the prompt. The prompt then needs to pop off those values and pass them to the handler. It so happens that this values-then-number-of-values convention is the same convention as is used for multiple-value returns -- so for compiled code what happens is that the compiler inlines the handler, and the VM just does a multiple-value bind on the values from the stack. (See truncate-values in the VM instruction docs.) That's what happens when `prompt' is compiled, as it is in eval.scm. But before eval.scm is compiled, we use eval.c, which also has to have support for prompt and abort; but it's necessarily a different mechanism. This commit fixed a bug in that mechanism: that instead of looking for the number-of-values marker (the exact integer that it was expecting) from the VM's stack, as unwound by the abort, it was looking for it at the VM's stack-pointer as seen when the prompt was created -- which necessarily is below any values returned to the prompt's abort handler. We didn't see this issue before because compiling eval.scm did not cause a `throw'. Interesting, no? But since I changed the implementation of ensure-writable-dir to one that probably throws, we see this error. Any other error that caused a `throw' to a `catch' to occur before eval.scm was compiled probably caused this error in the past. I don't know if we had any reports of it; I wouldn't be surprised. In any case, a tricky bug, and a good one to have fixed. We do have prompt and abort tests for the VM implementation. We don't run them with the boot evaluator, because we can't, not after eval.scm is compiled -- and anyway, now compilation causes throws at times, so we'll pick up these issues from users if it comes back. Hope that explains things :) Andy -- http://wingolog.org/