From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.user Subject: Re: Thread and guile environment Date: Sat, 10 Jul 2010 10:22:31 +0200 Message-ID: References: <20100705082310.GA9492@apc> <87630oe74w.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 1278763052 27912 80.91.229.12 (10 Jul 2010 11:57:32 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 10 Jul 2010 11:57:32 +0000 (UTC) Cc: guile-user@gnu.org To: Neil Jerram Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Jul 10 13:57:29 2010 Return-path: Envelope-to: guile-user@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 1OXYgP-0006Md-Dl for guile-user@m.gmane.org; Sat, 10 Jul 2010 13:57:29 +0200 Original-Received: from localhost ([127.0.0.1]:57269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OXYgM-0004fn-Ju for guile-user@m.gmane.org; Sat, 10 Jul 2010 07:57:22 -0400 Original-Received: from [140.186.70.92] (port=38819 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OXYgG-0004eS-PD for guile-user@gnu.org; Sat, 10 Jul 2010 07:57:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OXYgD-0008L3-UA for guile-user@gnu.org; Sat, 10 Jul 2010 07:57:15 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:57020 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OXYgD-0008KT-Qz for guile-user@gnu.org; Sat, 10 Jul 2010 07:57:13 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id E3569C30A1; Sat, 10 Jul 2010 07:57:07 -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=MUlKE0tkkEZ/0ey3v1m5loJ5Pm0=; b=NVf37o 1F3/1ytgKa8Xdd+oPoR/1CTS0BzkY7UT9yq1pw+M4MhO/odjyuIsAH0UyAv5lwbx QeyszOSx+ZLmXK0dHKac0lLb38Vd9CeERmlaTbRTYNp0Hy//WdoBVdlQTtRpSiv5 IfIeYYD0yAyNS+ejkWar5tf9U09w/okTOvEG4= 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=A8SqGEKT6Ld05pBqFSxV+4DEn6gk8YfZ qySddmydBqVpGZbvgSWGak/ziXzu+gFz50rFJGe1OD+r1VBw4ZHMIt1VjmZBmC5D XEhKPj+Db3H7CoEbWBd/IrnK4KXqTHgCrswgxSUTljOIIrSVlt4HwQTgzMmxGuEZ PHwYhpE92UY= Original-Received: from a-pb-sasl-quonix. (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id BC85FC30A0; Sat, 10 Jul 2010 07:57:05 -0400 (EDT) Original-Received: from unquote.localdomain (unknown [81.39.161.70]) (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 5C4E4C309F; Sat, 10 Jul 2010 07:56:59 -0400 (EDT) In-Reply-To: <87630oe74w.fsf@ossau.uklinux.net> (Neil Jerram's message of "Fri, 09 Jul 2010 21:23:59 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Pobox-Relay-ID: 4284E8E6-8C1A-11DF-BE95-9056EE7EF46B-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:7983 Archived-At: Hi, On Fri 09 Jul 2010 22:23, Neil Jerram writes: > Andy Wingo writes: > >> Interestingly, the first thread has you in (guile-user), but the second >> has you in (guile). So you don't see the full definition of format, nor >> do you see hug. > > That's what I thought too. But in that case I have no idea why my > '(define-module (guile-user))' suggestion didn't work. I think bug.scm was loaded in the main module -- the threads just tried to call a function defined by bug.scm, and as they were in (guile), not (guile-user), there was the error. >> But it's quite ugly. Does anyone have any input as to what module should >> be current when a thread previously unknown to Guile enters Guile? > > Surely it has to be (guile-user), since that what the end of boot-9.scm > moves into - and hence is well-established for the single thread case. Agreed. I just pushed the following patch, which fixes Cedric's case. commit a85f90f5ac5c3c5f830e295c0ca7b006141b1a83 Author: Andy Wingo Date: Sat Jul 10 10:21:22 2010 +0200 capture default dynamic state in (guile-user) * libguile/init.c (scm_i_init_guile): Move the call to scm_init_threads_default_dynamic_state after the call to scm_load_startup_files, so that the default dynamic state is in the (guile-user) module, not (guile). diff --git a/libguile/init.c b/libguile/init.c index 6313b65..4843910 100644 --- a/libguile/init.c +++ b/libguile/init.c @@ -570,8 +570,6 @@ scm_i_init_guile (SCM_STACKITEM *base) scm_i_init_deprecated (); #endif - scm_init_threads_default_dynamic_state (); - scm_initialized_p = 1; #ifdef STACK_CHECKING @@ -585,6 +583,10 @@ scm_i_init_guile (SCM_STACKITEM *base) atexit (cleanup_for_exit); scm_load_startup_files (); scm_init_load_should_autocompile (); + + /* Capture the dynamic state after loading boot-9, so that new threads end up + in the guile-user module. */ + scm_init_threads_default_dynamic_state (); } /* Andy -- http://wingolog.org/