From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: Trouble joining with threads from C Date: Fri, 15 Apr 2011 23:44:52 +0200 Message-ID: <87ipufdwa3.fsf@gnu.org> References: <87y64rzd5p.fsf@netris.org> <8762rswzzf.fsf@netris.org> <87vczdqtdx.fsf@gnu.org> <87ipuhzvvk.fsf@gnu.org> <877haxzvh6.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1302903909 6700 80.91.229.12 (15 Apr 2011 21:45:09 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 15 Apr 2011 21:45:09 +0000 (UTC) Cc: guile-devel@gnu.org To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Apr 15 23:45:05 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QAqp6-0001rn-Dr for guile-devel@m.gmane.org; Fri, 15 Apr 2011 23:45:04 +0200 Original-Received: from localhost ([::1]:41039 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAqp5-0003cd-Te for guile-devel@m.gmane.org; Fri, 15 Apr 2011 17:45:03 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:56164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAqp2-0003cF-Jr for guile-devel@gnu.org; Fri, 15 Apr 2011 17:45:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QAqp1-0004IN-EW for guile-devel@gnu.org; Fri, 15 Apr 2011 17:45:00 -0400 Original-Received: from solo.fdn.fr ([80.67.169.19]:53973) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAqp1-0004IG-AG for guile-devel@gnu.org; Fri, 15 Apr 2011 17:44:59 -0400 Original-Received: from nixey (reverse-83.fdn.fr [80.67.176.83]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) (Authenticated sender: lcourtes) by smtp.fdn.fr (Postfix) with ESMTPSA id EE104449D7; Fri, 15 Apr 2011 23:44:57 +0200 (CEST) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 26 Germinal an 219 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: (Andy Wingo's message of "Fri, 15 Apr 2011 10:41:42 +0200") User-Agent: Gnus/5.110015 (No Gnus v0.15) Emacs/23.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 80.67.169.19 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:12269 Archived-At: Hi Andy! Thanks for your explanations. Andy Wingo writes: > On Wed 13 Apr 2011 23:34, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > >> After reviewing f60a7648d5926555c7760364a6fbb7dc0cf60720 (which >> addressed the same issue), I lean towards reverting it and instead >> applying the patch I just sent. >> >> The problem I see with f60a7648d5926555c7760364a6fbb7dc0cf60720 is that >> it re-introduces a pthread_key, even when using TLS, and make things a >> bit complex IMO. > > The issue is that threads in Guile are not always spawned by Guile. > It's true that of the two cases in which Guile spawned a thread, one of > them wasn't getting the cleanup handlers called, and your patch fixes > that; but that ignores the case of threads that are spawned by a user's > program. Right, I was just focusing on Mark=E2=80=99s case, blissfully ignoring #324= 36. > For example in the following program: > > void* thread (void*) > { > scm_with_guile (do_something, NULL); > scm_with_guile (do_something_else, NULL); > return NULL; > } > > int main () > { > pthread_t thr; > pthread_create (&thr, NULL, thread, NULL); > pthread_join (thr, NULL); > return 0; > } > > When do you propose that the cleanup handlers for the thread be called? I=E2=80=99ll followup on this later, but currently it seems impossible to c= all GC_INIT from a thread other than the initial thread [0]. Thanks, Ludo=E2=80=99. [0] http://article.gmane.org/gmane.comp.programming.garbage-collection.boeh= mgc/4490