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: a little puzzle Date: Sun, 10 Oct 2010 16:58:04 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1286722782 26459 80.91.229.12 (10 Oct 2010 14:59:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 10 Oct 2010 14:59:42 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sun Oct 10 16:59:41 2010 Return-path: Envelope-to: guile-devel@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 1P4xN7-0002x7-Rt for guile-devel@m.gmane.org; Sun, 10 Oct 2010 16:59:39 +0200 Original-Received: from localhost ([127.0.0.1]:34855 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P4xN3-0006Af-Aw for guile-devel@m.gmane.org; Sun, 10 Oct 2010 10:59:29 -0400 Original-Received: from [140.186.70.92] (port=33775 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P4xMx-0005y6-BC for guile-devel@gnu.org; Sun, 10 Oct 2010 10:59:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P4xIi-0002li-SO for guile-devel@gnu.org; Sun, 10 Oct 2010 10:55:02 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:38556 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P4xIi-0002kK-Pz for guile-devel@gnu.org; Sun, 10 Oct 2010 10:55:00 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 7FBFBDD38F for ; Sun, 10 Oct 2010 10:54:36 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=CUGNqKl1XSjnxtmSt+DTT0AkQ/Q=; b=Og0fTX 9Ubfn4cFOcGUJBnzeyl+KDuAUrTv0obsPGEX/0BsmkhWBA5714BJdtTh9S3mfi6n Jdxpc3VzXtut6O9i1uLJg6YBtqOrkKr8c1n7rh66iJqNGjpTF6ivXv7jUJeV+69g bJpq60e5tlgmVjQCyDltTwsTTanI3NLUoGiMo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:subject :references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=OGcUKNSfHkJL2xFJqR79vSMI5HP1COd9 Ve3RszC4mNBMYyb5XNk/AKUkSVE8PAS1xofpa7rnXElzaHHlVHmyLWxsUXOmlDba AfSL2y34sZ2j8fWB7a6qqAWXV9mFRNaOB1RUvFRo7ss67D1WxXCwavFPNJhAqbwL 7cZ7f+5vTMQ= Original-Received: from a-pb-sasl-quonix. (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 7A29FDD38E for ; Sun, 10 Oct 2010 10:54:36 -0400 (EDT) Original-Received: from unquote.localdomain (unknown [81.39.169.13]) (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 B94E9DD38D for ; Sun, 10 Oct 2010 10:54:35 -0400 (EDT) In-Reply-To: (Andy Wingo's message of "Fri, 08 Oct 2010 19:32:25 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Pobox-Relay-ID: 4CD9EB00-D47E-11DF-A7E8-030CEE7EF46B-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11012 Archived-At: On Fri 08 Oct 2010 19:32, Andy Wingo writes: > On Fri 08 Oct 2010 19:14, Andy Wingo writes: > >> That's right: two throws for the price of one! The interrupted syscall, >> and then the asynchronous signal. Fun... > > I propose to fix it with a patch like this: > > --- a/libguile/error.c > +++ b/libguile/error.c > @@ -147,6 +147,7 @@ void > scm_syserror (const char *subr) > { > SCM err = scm_from_int (SCM_I_ERRNO ()); > + SCM_ASYNC_TICK; > scm_error (scm_system_error_key, > subr, > "~A", I did so, wrapping in #ifdef EINTR, and with the additional comment: /* It could be that we're getting here because the syscall was interrupted by a signal. In that case a signal handler might have been queued to run. The signal handler probably throws an exception. If we don't try to run the signal handler now, it will run later, which would result in two exceptions being thrown: this syserror, and then at some later time the exception thrown by the async signal handler. The problem is that we don't know if handling the signal caused an async to be queued. By this time scmsigs.c:take_signal will have written a byte on the fd, but we don't know if the signal-handling thread has read it off and queued an async. Ideally we need some API like scm_i_ensure_signals_delivered() to catch up signal delivery. Barring that, we just cross our digits and pray; it could be that we handle the signal in time, and just throw once, or it could be that we miss the deadline and throw twice. */ #ifdef EINTR if (scm_to_int (err) == EINTR) SCM_ASYNC_TICK; #endif -- http://wingolog.org/